我正在尝试生成一个无限数列表
0,1,-2,3,-4,5,-6...
到目前为止我得到了
evenise x | x == 0 = 0
| even x = -x
| otherwise = x
s = foldl (\x -> evenise x) 0 [1..]
但是我收到了错误
Occurs check: cannot construct the infinite type: a0 = b0 -> a0
In the first argument of `evenise', namely `x'
In the expression: evenise x
In the first argument of `foldl', namely `(\ x -> evenise x)'
我不明白错误,因为evenise
接受了一个元素,并且匿名函数(\x -> evenise x)
也接受了一个元素。