
16 Jun
2006
16 Jun
'06
6:06 p.m.
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
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