kowainik / slist

♾️ Sized list
https://kowainik.github.io/projects/slist
Mozilla Public License 2.0
46 stars 6 forks source link

Add `chunksOf` #24

Closed chshersh closed 3 years ago

chshersh commented 4 years ago

What do you think about adding the following function?

chunksOf :: Int -> Slist a -> Slist (Slist a)

For ordinary lists it would work like this:

ghci> chunksOf 3 [0..7]
[[0,1,2], [3,4,5], [6,7]]

But since we have access to the list length, we can implement a more efficient version of chunksOf.

vrom911 commented 4 years ago

Nice! I like the idea :+1: