我正在努力学习Haskell,认为它将是实现组合博弈论的完美语言.我在Python中已经在某种程度上做了这个,以自学OOP原则和运算符重载,但Haskell吸引我,因为它的语法似乎更具数学性,并且我有一个数学背景我非常喜欢它.此外,懒惰地实现无限列表是非常惊人的.
无论如何,到目前为止我所拥有的是一个编译的数据结构,但是我用它编写的第一个函数给了我:
Prelude> :l cgt
[1 of 1] Compiling Main ( cgt.hs, interpreted )
cgt.hs:8:30:
Couldn't match expected type `([Game], b0)' with actual type `Game'
In the first argument of `fst', namely `b'
In the second argument of `(:)', namely `(fst b)'
In the expression: a : (fst b)
Failed, modules loaded: none.
Run Code Online (Sandbox Code Playgroud)
这是我的代码......
--A game that is Zero (base case) is two empties
--Anything else must be two lists of games, a left list and a right …Run Code Online (Sandbox Code Playgroud)