linus sellberg <sellberg / google.com> Jan 28, 2005 at 02:12 PM wrote:
>georgesawyer wrote:
>>"Robert Klemme" <bob.news / gmx.net> Jan 25, 2005 at 09:09 AM wrote:
>>>did I mention that I love #inject? :-)
>>(Wistfully) Even though 'inject' is the name in Smalltalk, I feel it
>>were better named, 'consolidate'.
>I don't have anything against #inject, but I could see the case for an 
>alias #accumulate, much like SICP's accumulate which afaik is the same 
>thing.

>(I wouldn't mind #reduce as well, though that would be slightly
incorrect)

More fundamentally, I suggest 'collapse', because the most general concept
seems of collapsing away one dimension from a multi-dimensional thing.
Notwithstanding that the method should allow, perhaps, a scalar argument,
or no arguments. Pushing the concept to all dimensions would be done
instead first by flatten'ing, then by inject'ing (collapse'ing). Reducing
the dimensionality by one seems useful: here and there, I seem to have
heard of it.

I lack some comfort with 'inject', even after time: perhaps because it
asks us to pass the code for collapsing (an array of) objects, instead of
asking the objects to know how to collapse themselves: a known
object-programming principle. Collapse perhaps should be a module method
of no arguments, mix-inable to any class of objects having the '[]'
method.