[Haskell-cafe] Re: Embedding newlines into a string?
Neil Mitchell
ndmitchell at gmail.com
Mon Apr 14 05:00:04 EDT 2008
Hi
> > > mapM_ putStrLn (hanoi 2) -- outputs each move
> > in a new line
> > > putStrLn (unlines (hanoi 2)) -- same as
> > previous line
putStr (unlines (hanoi 2))
is what you want. Unlines puts a trailing new line at the end of every
line, including the final one. putStrLn puts an additional trailing
new line, so you get 2 at the end.
mapM_ putStrLn == putStr . unlines
Thanks
Neil
More information about the Haskell-Cafe
mailing list