Clojure style function "threading" in Python Clojure style function "threading" in Python python python

Clojure style function "threading" in Python


Or possibly use the reduce function in the following way:

reduce(lambda x,f : f(x), [f1,f2,f3], arg)


You can easily implement something like this yourself.

def compose(current_value, *args):    for func in args:        current_value = func(current_value)    return current_valuedef double(n):    return 2*nprint compose(5, double, double) # prints 20


Or try https://mdk.fr/blog/pipe-infix-syntax-for-python.htmlA module that provide a syntax like :

  fib() | take_while(lambda x: x < 1000000)        | where(lambda x: x % 2)        | select(lambda x: x * x)        | sum()