Benjamin L. Russell wrote:
Wow, that's very general.  So you want to divide hanoi
into a main function, a helper function, and a display
function.

I tried it out, and got this far so far:

[...]

hanoi_shower :: Show a => [(a, a)] -> String
hanoi_shower [(a, b)] = "Move " ++ show a ++ " to " ++
    show b ++ "."

That's exactly what I was thinking about, but your hanoi_shower only
handles list of exactly one action, but you have to handle longer lists,
too. This could be done with explicit recursion

  hanoi_shower [] = ...
  hanoi_shower ((a, b) : moves) = ...

or (preferably) with map

hanoi_shower moves = unlines (map show_move moves) where
  show_move (a, b) = ...

Note the use of unlines again. I decided to use where to introduce a
local binding to avoid cluttering the top-level scope with function names.

  Tillmann
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to