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]
>> [1,2,3].drop 1
=> [2, 3]
>> [1,2,3].first
=> 1
Of course, as you know, these aren't too close to Lisp. The real ruby equivalent would be something like [1, [2, [3, nil]]]
. You could always write a List class...or find one somewhere.
Chapter 8 of Practical Ruby Projects is called Implementing Lisp in Ruby.