我在纸上有一个haskell函数作为例子:
function2 a b c = (a * b) + c
Run Code Online (Sandbox Code Playgroud)
我需要用无点表示法编写示例.我真的很擅长使用无点样式,因为我发现它真的很混乱,没有适当的指导,所以我尝试了一下:
function2 a b c = (a * b) + c
function2 a b c = ((*) a b) + c #operator sectioning
function2 a b c = (+) ((*) a b)c #operator sectioning once more
#I'm stuck here now
Run Code Online (Sandbox Code Playgroud)
我不确定接下来会发生什么,因为这是我能想到的这个例子的限制.希望得到一些帮助.
- 第二个例子:
function3 a b = a `div` (g b)
function3 a b = `div` a (g b) --operator sectioning
function3 a b = (`div` a) (g b) …Run Code Online (Sandbox Code Playgroud) 我很困惑Haskell中的where子句在某种情况下是如何工作的.
我最大的问题是,是否有可能来声明一个变量,做的东西在where子句和使用回到那个声明的变量,通过另一个变量的where子句中声明?
例如:
someFunc :: somefunc
.
| (guard expression)
| (guard expression)
where a = 1+3
b = a + 2 --using back 'a' variable which was also declared in the where clause.
Run Code Online (Sandbox Code Playgroud)
这可能吗?当我这样做时,haskell不报告任何错误,但我怀疑它是否正确.