问题
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