I would like to print a char underlining a String n times, with n the length of the String in Haskell.
How should I do this?
My String is: \"Available Chars (x)\
Use replicate:
underline :: String -> String
underline = flip replicate '-' . length
This will give you a string which is n times the character '-' where n is the length of the input string. It is the same as:
underline = map $ const '-'
You can then use it like this (if for example yourString = "Available Chars (111)"
):
> putStrLn yourString >> putStrLn (underline yourString)
Available Chars (111)
---------------------