Closed ntreu14 closed 3 years ago
I love this function, but it is already in elm/core
as List.filterMap
.
@Chadtech Wow, thanks for the heads up! I've never seen it called that before so didn't recognize it. I shoulda searched for the function signature.
Thanks for letting me know it already exists!
I've implemented this a couple times in smaller personal projects of mine. I've seen this function implemented in the core libraries of Haskell and F# (called
choose
in F#).You can think of this function as doing a
filter
andmap
in one. Although this is a very contrived example, you an easily imagine one more complex:There are also other situation where you have a function that might return a
Maybe
and you can directly apply that function to a list of elements to only get back a list where it isJust a
.Let me know what you think. I'd love to hear thoughts!