Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Baishampayan Ghose
Does mapcat work? Or may be reduce with merge after the map? An example would help. ~BG On Thu, Apr 11, 2013 at 8:56 AM, Steven Degutis wrote: > The idea I already have in mind is to pass a function to map that returns a > sequence whose size can vary, and flatten the results of the map. > > This

Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Steven Degutis
Wow, that works perfectly and it's really elegant! Glad I asked, thanks :) -Steven On Wed, Apr 10, 2013 at 10:32 PM, Andy Fingerhut wrote: > Since you are dealing with maps, this might not be exactly what you need, > but try it out and tweak it as needed: > > (mapcat f coll) = (apply concat (ma

Re: Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Andy Fingerhut
Since you are dealing with maps, this might not be exactly what you need, but try it out and tweak it as needed: (mapcat f coll) = (apply concat (map f coll)) Andy -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Best way to (map) a sequence, but return 0-n items per input item?

2013-04-10 Thread Steven Degutis
The idea I already have in mind is to pass a function to map that returns a sequence whose size can vary, and flatten the results of the map. This will probably work, but is there a more elegant way? What about more efficient? Note: the items returned will be Clojure maps. -Steven -- -- You