haskell-cafe@haskell.org
[Top] [All Lists]

Re: Embedding newlines into a string? [Was: Re: [Haskell-cafe] Separate

Subject: Re: Embedding newlines into a string? [Was: Re: [Haskell-cafe] Separate a string into a list of strings]
From: "Neil Mitchell"
Date: Mon, 14 Apr 2008 08:30:33 +0100
Hi



On Mon, Apr 14, 2008 at 8:22 AM, Benjamin L. Russell
<dekudekuplex@xxxxxxxxx> wrote:
> A friend and I were working on a Haskell version of
>  Towers of Hanoi yesterday, and I tried writing out the
>  program today, but got stuck on outputting newlines as
>  part of the string; viz:

>     | n == 1 = putStrLn ("Move " ++ show source ++ " to
>  " ++ show dest ++ "." ++ show '\n')

show '\n' = "\\n"

"\n" == "\n"

Therefore:

>     | n == 1 = putStrLn ("Move " ++ show source ++ " to
>  " ++ show dest ++ "." ++ "\n")

Note that you need the brackets, an in general don't call show on a
String or a Char.

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>