From: Bruce Williams Date: 2002-10-22T06:27:19+09:00 Subject: Re: Difference between inject and reduce On Monday 21 October 2002 03:34 pm, Travis Whitton wrote: > Also, when > using ruby in a functional style is there a better way to get the > traditional car and cdr of an Array than array.first, array[1, > array.length]? I understand that an array is not the same thing as a > "list", but I'm just thinking convience here. I'd just change it to: car, cdr = array[0], array[1..-1] # for brevity Of course, you could use partition, but that's fairly heavy handed. If I needed this often enough I'd add... class Array def car; first; end def cdr; self[1..-1]; end end ... for convenience. Any other suggestions? ~ Bruce