我想了解部分,並認爲我已經明白了。基本上它是將部分應用程序應用於二元運算符的一種方法。所以我明白了所有的(2*)
,(+1)
等例子就好了。部分 - 爲什麼我需要在這裏?
但在O'Reilly的真實世界哈斯克爾書,第「部分的」 :)它有這個例子:
(`elem` ['a'..'z']) 'f'
>True
我明白了括號的需要 - 即部分語法。但爲什麼我需要反引號?
如果我嘗試,我得到:
(elem ['a'..'z']) 'f'
<interactive>:220:19:
Couldn't match expected type `[[Char]]' with actual type `Char'
In the second argument of `elem', namely 'f'
In the expression: (elem ['a' .. 'z']) 'f'
In an equation for `it': it = (elem ['a' .. 'z']) 'f'
我認爲你對coypasting做了一個錯誤:你的第二個例子應該是沒有'elem'反引號,並且沒有'> True'作爲答案。 – enrique
@enrique對不起,我已更正。 –