tandav / pipe21

Simple functional pipes for python
https://tandav.github.io/pipe21
MIT License
18 stars 1 forks source link

add take, chunked #6

Closed tandav closed 2 years ago

tandav commented 2 years ago

# https://more-itertools.readthedocs.io/en/stable/api.html
def take   (n, iterable): return list(itertools.islice(iterable, n))
def chunked(iterable, n): return iter(functools.partial(take, n, iter(iterable)), [])