dimanche 13 mars 2016

Printing a String 'N' times in Haskell

I am really new with Haskell. I am trying to improve my code by printing "Hi" in this order. For example n = 4, the output is:

Hi
Hi Hi
Hi Hi Hi
Hi Hi Hi Hi

My current code is:

printHi :: Integer -> String
printHi n = concat["Hi" | n <- [0..n-1]]

and its output is:

Hi Hi Hi Hi

Any tips on how I will be able to perform this task? Thanks

Aucun commentaire:

Enregistrer un commentaire