jim burton wrote:
> I want to split a string into 5 parts of equal length, with the last fifth
> padded if necessary, but can't get it right - here's what I've got - 

fifths s = unwords.take 5.unfoldr (Just . splitAt l) $ s ++ repeat ' '
  where l = (length s + 4) `div` 5 


Of course no Haskeller in his right mind would carelessly apply the
final 'unwords' unless this was for immediate output.


Udo.
-- 
The Second Law of Thermodynamics:
        If you think things are in a mess now, just wait!
                        -- Jim Warner

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to