17 Jun
2006
17 Jun
'06
6:06 a.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 <trevion@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