Anonymous user
Towers of Hanoi: Difference between revisions
→{{header|Haskell}}: laziness is better than tail recursion
(add Tcl) |
(→{{header|Haskell}}: laziness is better than tail recursion) |
||
Line 344:
hanoi :: Integer -> a -> a -> a -> [(a, a)]
hanoi
hanoi n a b c = hanoi
One can use this function to produce output, just like the other programs:
Line 359 ⟶ 356:
hanoiM :: Integer -> IO ()
hanoiM n = hanoiM' n 1 2 3 where
hanoiM' 0
hanoiM' n a b c = do
hanoiM' (n-1) a c b
|