prelude-ls
prelude-ls copied to clipboard
Map ok
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 ()
).
You say you end up using an extra compact
, although it strips all falsy values, not just void
s and null
s. 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.