'how do I present number of spaces in haskell [duplicate]

I am just learning Haskell. I am trying to present a number of spaces using a variable. For example, if I have a function:

function (a,x,b)

It should result in something like this

a ++ " "*(x) ++ b


Solution 1:[1]

You can obtain a string with a given number of spaces with replicate :: Int -> a -> [a], for example:

Prelude> replicate 0 ' '
""
Prelude> replicate 1 ' '
" "
Prelude> replicate 2 ' '
"  "
Prelude> replicate 3 ' '
"   "

I leave implementing the rest of the function as an exercise.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Willem Van Onsem