我想知道我们是否可以在匿名函数中使用或不使用.我试着这样做:
\x -> k where k = x+1
Run Code Online (Sandbox Code Playgroud)
但是这会在'where'上给出一个解析错误.
您可以where在lambda表达式中的某些表达式中使用,但不能仅在内部使用.
f = \x ->
case x of
Nothing -> 12
Just y -> z * 2
where z = y + 7
Run Code Online (Sandbox Code Playgroud)