hpastetwo

.

author
.
age
40 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
.
age
40 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