
23 Oct
2006
23 Oct
'06
5:39 p.m.
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