In addition to PiotrLegnica's answer: Often it is easier to read if you declare a helper function instead of using lambda. Consider this:
map helper [1..4] where helper x | even x = x `div` 2 | otherwise = x
( [1..4] - sugar for [1,2,3,4] )
If you want to remove all other elements, consider using filter . filter removes all elements that do not satisfy the predicate:
filter even [1..4] -> [2,4]
So, you can build a map pipe and filter, than instead, use the following instead:
map (`div` 2) $ filter even [1..4] [x `div` 2 | x <- [1..4], even x]
Choose what you like best.
fuz
source share