Haskell - parse error on input `=' [duplicate]

心不动则不痛 提交于 2020-01-17 04:32:28

问题


when implementing the code for the "Towers of Hanoi" problem I get the following error message:

hanoi.hs:4:24: parse error on input `='
Failed, modules loaded: none.

Here is the code:

hanoi 1 i j = [(i, j)]
hanoi n i j = hanoi n' i otherT ++ [(i,j)] ++ hanoi n' otherT j
    where   n' = n-1
            otherT = 1+2+3-i-j

Any Ideas?


回答1:


Your editor and the compiler see the tabs differently. Avoid using tabs and indent with spaces:

hanoi 1 i j = [(i, j)]
hanoi n i j = hanoi n' i otherT ++ [(i,j)] ++ hanoi n' otherT j
    where   n' = n-1
            otherT = 1+2+3-i-j

Good editors can be set up to do the right number of spaces automatically when you press tab.



来源:https://stackoverflow.com/questions/24842552/haskell-parse-error-on-input

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!