3 ms·
Haskell also has it in the Data.List.Split library, which is handy, although it's easy to define yourself. λ> chunksOf 3 [1..12] [[1,2,3],[4,5,6],[7,8,9],[10,
by anaphor 13y ago
Haskell also has it in the Data.List.Split library, which is handy, although it's easy to define yourself.
λ> chunksOf 3 [1..12]
[[1,2,3],[4,5,6],[7,8,9],[10,11,12]]