4 ms·
task3(task2(task1(work))) can, with the function apply(data, *funs): return reduce(lambda d, f: f(d), [data] + funs) be rewritten as apply(w
by joshuamorton 9y ago
task3(task2(task1(work)))
can, with the function
apply(data, *funs):
return reduce(lambda d, f: f(d), [data] + funs)
be rewritten as
apply(work, task1, task2, task3)
Its possible in exactly the same set of cases, namely those where each task takes a single argument/is provided as a partial.
I expect that `->` is implemented in clojure in much the same way (and [1] implies that, modulo some scaffolding and error checking, it is, although with a recursive, inlined impl of reduce)
[1]: https://github.com/clojure/clojure/blob/08e592f4decbaa08de570ded9ac169785b1608f9/src/clj/clojure/core.clj#L1669 https://github.com/clojure/clojure/blob/08e592f4decbaa08de57...
- kamaal 9y agoSorry but again, using a workaround doesn't mean they are the same. When I mean same, I mean structurally.
- joshuamorton 9y agoBut they are structurally the same that's my point. I can implement -> practically directly. There is no structural difference that you've demonstrated. That is not idiomatic and common in Python didn't mean that there is some structural difference. Basically the transformations you're describing are doable with regex, which is the opposite of powerful. What you've done is take code is data, which is powerful, and confuse that with "supports varags", which is less powerful, and claim that the second is unique and powerful when it is not unique, and not uniquely powerful.