import Data.List import Data.Tuple import Control.Arrow import Control.Monad main :: IO () main = do zipWithM_ (f >>> (>>> print)) [3..7] $ replicate 3 [1..10] zipWithM_ (g >>> (>>> print)) [3..10] $ replicate 3 [1..10] ++ replicate 3 [1..15] print $ f465 "We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris." f :: Int -> [a] -> [[a]] f = (flip divMod >>> (length >>>)) >>> (>>> swap) >>> (>>> ((((first signum >>> uncurry (+)) >>= flip (fst >>> replicate)) &&& (snd >>> repeat)) >>> (uncurry (++)))) >>> (>>= flip (mapAccumL (flip splitAt >>> (>>> swap)))) >>> (>>> (snd >>> takeWhile (null >>> not))) g :: Float -> [a] -> [[a]] g n xs = map (\i -> let b = ceiling $ (i - 1) * a in take (ceiling (i * a) - b) $ drop b xs) [1..n] where a = (fromIntegral $ length xs) / n f465 :: String -> [(Char, Int)] f465 = sort >>> group >>> map (head &&& length)