我有一个这样的函数
f d = foldl (acc x -> acc ++ [distance] where distance = 1) d [1..3]
对于某些GHCI表示:
error: parse error on input ‘where’
where
子句适用于声明组,而不适用于表达式。您使用let
代替:
(acc x -> let distance = 1 in acc ++ [distance])