[Haskell-cafe] putStrLn
minh thu
noteed at gmail.com
Fri Jun 16 18:06:36 EDT 2006
you already know how to write "*" one ... so you just have to know how
to do it the neded amount :
two ways : 1/ you repeat the function
2/ you reapet the data one which the function is applied.
this is like 2/
2006/6/16, J. Garrett Morris <trevion at gmail.com>:
> main n = putStrLn (replicate n '*')
>
> main n = putStrLn (take n (repeat '*'))
this is like 1/
> main n = sequence (take n (repeat (putStr "*")))
in order to remove the interleaved '\n', just apply the trick (n-1)
times then one more for '\n'.
> (but that doesn't have a final new line. The more complicated:
>
> main n = sequence (take (n - 1) (repeat (putStr "*"))) >> putStrLn "*"
>
> should solve that problem.)
>
mt
More information about the Haskell-Cafe
mailing list