prelude-ls icon indicating copy to clipboard operation
prelude-ls copied to clipboard

Map ok

Open misterfish opened this issue 8 years ago • 1 comments

Hi,

My proposal is a map-ok function, which is identical to map, except that returning undefined or null will remove the element from the output list.

The use case is that I often find myself wanting to remove an element while I'm mapping, and end up using an extra compact. It would be nice to be able to do it the first time around. (cf. Perl, for example, where you can return ()).

misterfish avatar May 08 '16 01:05 misterfish

You say you end up using an extra compact, although it strips all falsy values, not just voids and nulls. And I actually more often find myself wanting all falsy values out, than just all nully values.

PS. that works as a value of expressions in the when clauses too.

pepkin88 avatar Oct 21 '16 13:10 pepkin88