>
> Clojure has a function (({into})) that might fit the bill.
>>
>
> This indeed looks very promising.


I like the sound of 'into', but am not sure about appending results with
the '<<' operator. If Hash had '<<' and '+' aliases for 'update' and
'merge' (respectively), we might as well give 'map' an optional argument,
and call:

    [1,2,3].map({}) {|i| { i => i ** 2 } }

And if Hash#update accepted a two-element array, we could do:

    [1,2,3].map({}) {|i| [i, i ** 2] }

So I like the 'into' name, but I think it would be more useful as an alias
for 'each_with_object', instead of just 'map' with an argument for the base
object.



> I often want a "collect" method where I'm not forced to collect exactly
> one item per item of the original collection. If collect weren't an alias
> to map, I think it would even make a lot of sense to use the word "collect"
> for this (map: one-to-one, collect: one-to-many).
>

Ruby has a 'flat_map' method (aliased as 'collect_concat') that flattens
the first level of a returned array, so you can append multiple results,
and don't need to use compact. See
http://ruby-doc.org/core-1.9.3/Enumerable.html#method-i-flat_map

    [1,nil,2].flat_map {|i| i ? [i] : [] }    #=> [1, 2]


Best,
Nathan