I've written this function using map
, but I need to write this using list comprehension:
alter = map (\x -> if x == 0 then 1 else 0)
it gives e.g.
alter [1,1,0]
> [0,0,1]
You can't write it point-free using list comprehension:
alter xs = [if x == 0 then 1 else 0 | x <- xs]