Suppose you want mapa collection, but only collect the results of the displayed function if the displayed value meets certain criteria. I am currently doing this as such:
func = foldl (\acc x, -> (maybeGrab x):acc) []
maybeGrab a
| a > 5 = [someFunc a]
| otherwise = []
While this works, I am sure that there is a more idiomatic way of “right / general / more recognizable”.
source
share