You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most common usage of concatMap for me is to simply flatten a sequence. It'd be nice if there were a zero-argument form that assumes a default of the id function so thatconcatMap() is equivalent to concatMap{|x| x}
I'm not 100% sure about this, since no other terms that take a function default to the identity function if one isn't provided. (Although, thinking about it, the convention would make sense for filter too; seq.filter would mean "remove all instances of false and nil from the sequence".)
Another option would be to introduce a flatten term.
tbh, the flatten term would probably be nicer/more explicit. This just happens because I want the concat but don't need the map and it's kinda verbose.
Activity
danielmewes commentedon Dec 12, 2014
I think that's a good idea. I would suggest we do it together with #334 .
mlucy commentedon Dec 13, 2014
I'm not 100% sure about this, since no other terms that take a function default to the identity function if one isn't provided. (Although, thinking about it, the convention would make sense for
filtertoo;seq.filterwould mean "remove all instances offalseandnilfrom the sequence".)Another option would be to introduce a
flattenterm.deontologician commentedon Dec 13, 2014
tbh, the flatten term would probably be nicer/more explicit. This just happens because I want the
concatbut don't need themapand it's kinda verbose.deontologician commentedon Dec 13, 2014
I think empty args means identity would work for most terms that require a function, but most of them would be kinda useless.
segphault commentedon May 6, 2015
👍
I recently ran into a situation where I used
concatMapto combine a bunch of arrays into a single array:I think it would make sense to be able to use
concatMapwithout an argument to achieve the desired outcome.