fork download
  1. import Data.List
  2. import Data.Tuple
  3. import Control.Arrow
  4. import Control.Monad
  5. main :: IO ()
  6. main = zipWithM_ ((print .) . f) [3, 4, 6, 7] $ replicate 4 [1..10]
  7. f :: Int -> [a] -> [[a]]
  8. f = ((takeWhile (not . null) . uncurry (flip (++)) . first (: [])) .) . ((flip (mapAccumL ((swap .) . flip splitAt)) =<<)) . ((uncurry (++) . ((flip (replicate . fst) =<< (uncurry (+) . first signum)) &&& repeat . snd)).) . (swap .) . ((. length) . flip divMod)
  9.  
Success #stdin #stdout 0s 6236KB
stdin
Standard input is empty
stdout
[[1,2,3,4],[5,6,7],[8,9,10]]
[[1,2,3],[4,5,6],[7,8],[9,10]]
[[1,2],[3,4],[5,6],[7,8],[9],[10]]
[[1,2],[3,4],[5,6],[7],[8],[9],[10]]