-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One-off pipes #94
One-off pipes #94
Conversation
partial-like syntax for pipe construction
It works, but is it really usefull? If you have a nice, striking example, please write it in the README.md to document the feature (without documentation it will never be used). |
It naturally extends the pattern provided by the existing curying examples. some_iterable | Pipe(some_func, 1, 2, 3) It's a little bit hard to add a specific example that fits the readme pattern of decorating functions with |
Playing around itertools there's a few "interesing" ones we could pick: >>> list(range(10) | Pipe(itertools.accumulate, initial=1))
[1, 1, 2, 4, 7, 11, 16, 22, 29, 37, 46]
>>> list(range(10) | Pipe(itertools.batched, 2))
[(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)]
>>> list(range(5) | Pipe(itertools.chain, range(5)))
[0, 1, 2, 3, 4, 0, 1, 2, 3, 4]
>>> list(range(5) | Pipe(itertools.combinations, r=2))
[(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
>>> list(range(20) | Pipe(itertools.compress, selectors=[1, 0] * 10))
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
>>> list(range(20) | Pipe(itertools.compress, selectors=[0, 1] * 10))
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
>>> list(range(20) | Pipe(itertools.islice, 5, 10))
[5, 6, 7, 8, 9] maybe based on this we can imagine a "good" example? |
I think that all of the examples you've provided are good and demonstrate exactly my intentions with the syntax. However I still don't yet see how they fit the flow of the current documentation. |
Feels like it should be documented under Feels like it goes near the Just don't forget to run |
Added section describing the usage to readme, "One-off pipes"
|
Thanks! |
partial-like syntax for pipe construction
#93