Wow, what an incredible project and a fantastic idea! When I first came across this repository, it immediately reminded me of the Rust iterator and its ability to chain multiple methods on an iterator in a lazy manner. It got me thinking about how great it would be to implement some of those operations, just like in Rust iterators.
For example:
... | <Pipe function> | collect(factory) instead of factory(... | <Pipe function>) to PIPE ALL!
Creating more official operators that are both practical and captivating for users. Here are some potential examples:
@Pipe
def step_by(iterable, step):
"Yield one item out of 'step' in the given iterable."
for i, item in enumerate(iterable):
if i % step == 0:
yield item
@Pipe
def reduce(iterable, predicate):
"Reduce the given iterable to one element using the given criterion."
return functools.reduce(predicate, iterable)
@Pipe
def position(iterable, predicate):
"Get the position of the element in the iterable."
for i, item in enumerate(iterable):
if predicate(item):
return i
@Pipe
def next_chunk(iterable, n):
...
something more
If you consider it to be practical, I would be delighted to contribute.
Wow, what an incredible project and a fantastic idea! When I first came across this repository, it immediately reminded me of the Rust iterator and its ability to chain multiple methods on an iterator in a lazy manner. It got me thinking about how great it would be to implement some of those operations, just like in Rust iterators. For example:
... | <Pipe function> | collect(factory)
instead offactory(... | <Pipe function>)
to PIPE ALL!@Pipe def reduce(iterable, predicate): "Reduce the given iterable to one element using the given criterion." return functools.reduce(predicate, iterable)
@Pipe def position(iterable, predicate): "Get the position of the element in the iterable." for i, item in enumerate(iterable): if predicate(item): return i
@Pipe def next_chunk(iterable, n): ...
something more