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

1

0

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?

Azedarach answered 19/7, 2014 at 16:33 Comment(1)
Seems you have mixed tabs and spaces.Jawbreaker
I
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.

Incest answered 19/7, 2014 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.