Are there ruby equivalents to the lisp car, cdr, and cons functions? For those unfamiliar with lisp, here’s what I want from ruby:
[1,2,3].car => 1
[1,2,3].cdr => [2,3]
[2,3].cons(1) => [1,2,3]
(in lisp):
(car '(1 2 3)) => 1
(cdr '(1 2 3)) => (2 3)
(cons 1 '(2 3)) => (1 2 3)
Ruby arrays are not implemented as singly-linked lists, so it is not as useful to have car and cdr and stuff.
If you really wanted, you could do