I am trying to understand why my code doesn't work:
writeRow :: Int -> IO()
writeRow x = putStr(concat (replicate x "* "))
triangle :: Int -> IO()
triangle x = do
writeRow x
putStr ""
triangle x-1
My thinking is, that writeRow creates a row of x times " * ", so if x = 4, triangle 4 will write
* * * *
As triangle is called recursivly with x -1, the next line will be:
* * *
And so on ... until:
* * * *
* * *
* *
*
But it just outputs it all on one line:
* * * * * * * *
What seems to be the issue? :D