Re:Show HN: Python library for functional programming
by entilzha on Monday December 18, 2017 @10:45PM
(#15957571)
Not OP, but author. Line continuation is pretty annoying. Adding custom methods wouldn't be hard (https://github.com/EntilZha/PyFunctional/issues/113), I just don't have time right now to add it.
With respect to _, this would make these two equivalent: a = lambda x: x + 1 b = _ + 1 a(1) == b(1)
Is there an expanded example I could look at for the pipe stuff, I haven't used clojure before
Re:Show HN: Python library for functional programming
by senand on Thursday December 14, 2017 @02:30PM
(#15925981)
Are you aware of the thread_first and thread_last functions from toolz?
Re:Show HN: Python library for functional programming
by andreareina on Thursday December 14, 2017 @05:54PM
(#15928045)
I wasn't thanks for the pointer!
My big issue with method chaining is exactly the one of requiring the line-continuation-escape, or enclosing the whole thing in parens. You also need to wrap the initial value, then possibly unwrap it at the end, and you're limited to the methods you define (mind you, this seems like a pretty comprehensive list).
For this reason I decided to emulate clojure's threading macros instead, as a pair of functions:
Unfinished is the version that makes `(callable, ...args..., _, ...more_args...)` work, is that what you mean by the _ lambda operator?