
23 Oct
2006
23 Oct
'06
4:21 p.m.
jim burton
*Main> fifths "IDOLIKETOBEBESIDETHESEASIDE" "IDOLI KETOBE BESIDE THESEA SIDEXX" *Main> fifths "12345" "1 23 45" (snip)
FWIW this unholy thing works for me, fifths :: String -> String fifths = splitIntoN 5 splitIntoN :: Int -> String -> String splitIntoN n string = let stringToSplit = string ++ replicate (n-1) 'X' in unwords (map fst (take n (tail (iterate (splitAt (div (length stringToSplit) n) . snd) (undefined, stringToSplit))))) Admittedly, a 'let' might be nice to name some intermediate computations. -- Mark