-
Notifications
You must be signed in to change notification settings - Fork 202
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
Function Composition #32
Comments
Unfortunately, F(x) >> foo >> bar >> baz
pipe(x) >> foo >> bar >> baz The only one problem that I see, is that python is strictly evaluated and we need to decide on each reducing step what to do: keep going with new functions or evaluate final result. Possible, we need something like "sentinel" function to execute whole pipe: pipe(x) >> foo >> bar >> baz >> end or pipe(x) >> foo >> bar >> baz >> result or even pipe.start(x) >> foo >> bar >> baz >> pipe.end What do you think about such syntax? Can you give a shining example where it's useful? |
A lot of my methods tend to look like:
Lately, I've begun to work with just functions. It feels more Pythonic.
or even,
|
creese, where is the above By the way, how is this little sugar for
Some examples to follow
and
Any thoughts? EDIT: Fix |
Earlier today I had the crazy idea to do something like this by abusing some operators (or and invert): mod_primes = ~(pipe(primes)
| filter(lambda a: a > 20)
| map(lambda a: a * a)
| zip_index
) A simple implementation is at: https://gist.github.com/venuatu/0b35e331aeea9f3feb8f Would this be a good addition for this library? |
Your implementation refers to lists but it actually can work for any type, does'nt it? |
Often, when I chain functions, I find myself using the following pattern:
(F() >> foo >> bar >> baz)(x)
If this were clojure, I could write:
(-> x foo bar baz)
Notice the input on the left. Is there any to way to do this in python/fn?
The text was updated successfully, but these errors were encountered: