USE*_*SFU 0 haskell list-comprehension pointfree
我已经编写了这个函数map,但是我需要使用list comprehension来编写它:
alter = map (\x -> if x == 0 then 1 else 0)
Run Code Online (Sandbox Code Playgroud)
它给出了例如
alter [1,1,0]
> [0,0,1]
Run Code Online (Sandbox Code Playgroud)
你不能使用list comprehension无点编写它:
alter xs = [if x == 0 then 1 else 0 | x <- xs]
Run Code Online (Sandbox Code Playgroud)