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?

jamafu
  • 13
  • 8

1 Answers1

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.

AndrewC
  • 32,300
  • 7
  • 79
  • 115