[Haskell-cafe] Pls help about stupid question!

iliali16 iliali16 at gmail.com
Tue Mar 6 14:56:34 EST 2007

Hi folks I have this funciton to implement : leftJustified 
Now this function shoud justify the text acording to the number of
characters per line.So for example I u put the following 

leftJustified :: Integer -> String -> String 
leftJustified n xs 

acctually my problem is that I have for example the following string 
Hi my name is X. And what I want is to leftJustified it by 3 characters and
I have to do it whithout choping words and I have to do it on the next line
and what I came up is very stupid becouse it doesn't work at all like what I
need but atleast it shows the string eventhough it counts not the characters
but the words. 

leftJustified :: Integer -> String -> String 
leftJustified 0 xs = [] 
leftJustified _ [] = [] 
leftJustified n xs 
        |lList (words xs) <= n = xs 
        |otherwise = x : \n (leftJustified xs) 

This doesnt work but if I delete the last line it owrks as shown above. 
Please help me to understand how this should be done. 

View this message in context: http://www.nabble.com/Pls-help-about-stupid-question%21-tf3357906.html#a9339801
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list