0

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]
Cactus
  • 27,075
  • 9
  • 69
  • 149
USERSFU
  • 69
  • 10

1 Answers1

5

You can't write it point-free using list comprehension:

alter xs = [if x == 0 then 1 else 0 | x <- xs]
Cactus
  • 27,075
  • 9
  • 69
  • 149