hpastetwo

.

author
.
age
37 days
language
haskell
1
2
3
4
5
6
-- | Takes a list, and splits it into sublists with specified granularity
chunkify :: [[a]] -> Int -> [[a]]
chunkify (c:cs) chunkSize = [firstChunk] ++ [chunk] ++ cs
  where
    firstChunk = chunkify [remainder] chunkSize
    (remainder, chunk) = splitAt chunkSize c

.

author
cygnus
age
37 days
language
haskell
1
2
3
4
5
-- | Takes a list, and splits it into sublists with specified granularity
chunkify :: [a] -> Int -> [[a]]
chunkify cs chunkSize = [firstChunk] ++ chunkify rest chunkSize
  where
    (firstChunk, rest) = splitAt chunkSize cs