有时我看到一些带有以下表达式的示例代码:
example = example' []
Run Code Online (Sandbox Code Playgroud)
或者有什么不同:
foldl
foldl'
Run Code Online (Sandbox Code Playgroud)
谢谢
GHCi> compare 2 3
LT
GHCi> compare 3 3
EQ
GHCi> compare 4 3
GT
Run Code Online (Sandbox Code Playgroud)
我认为情商意味着平等,但LT和GT是什么意思?
我在代码中看到像这样使用的斜杠:
solution([X/Y|Others]) :-
noattack(X/Y, Others).
Run Code Online (Sandbox Code Playgroud)
但有时我会在Prolog中看到"/ 1""/ 2"等.
这些陈述(字符)是什么意思?
假设有一个名为"smallc"的函数
smallerc :: Integer -> (Integer->Integer)
smallerc x y = if x <=y then x else y
Run Code Online (Sandbox Code Playgroud)
为什么不使用以下方式声明函数:
smallerc :: (Integer -> Integer) ->Integer
Run Code Online (Sandbox Code Playgroud)
谢谢!
我写了一个函数叫product
:
product [] = 1
product (x:xs) = x * product xs
Run Code Online (Sandbox Code Playgroud)
当我将其加载到WinHug中时:
错误文件:.\ product.hs:4 - 模糊变量发生"产品"
***可参考:Main.product Hugs.Prelude.product
这是什么意思?