I am trying to execute few statements in my function in Haskell, I looked online and got the idea that may be if I use "do" I can be able to do that.I used that but it still is not working for me, If some one can please have a look and guide me what I am doing wrong, I have just started with haskell, so its a little struggle with Haskell syntax.
My function:
type Rod = String
Move = (Integer, Rod, Rod)
hanoi :: Integer -> Rod -> Rod -> Rod -> [Move]
hanoi n source helper destination= if n==1 then [(n source destination)] else do
(hanoi (n-1) source helper destination)
([n source destination])
(hanoi (n-1) helper destination source)
I am trying to do the towers of Hanoi problem.and I want to execute the three statements that are after "do". Any help would be highly appreciated .
Thanks in advance!!!
=(or->in case expressions) is an expression.doblocks are fancy expressions, but not appropriate for this use case. For your case, you really should think about what the result needs to be. Then write an expression describing it.listof moves - you have to concat the results somehow ;) .... also to the downvoters: shame on you - this is a good question - maybe not PhD level but please keep the community friendly to beginners!