Skip to content

Instantly share code, notes, and snippets.

@0atman 0atman/ forked from anonymous/
Last active Jan 5, 2018

What would you like to do?
clojure `->`-style functional threading
from functools import reduce
def thread(*args):
"functional thread, inspired by clojure and"
caller = lambda x, y: y(x)
return reduce(caller, args[1:], args[0])

This comment has been minimized.

Copy link
Owner Author

commented Jan 5, 2018

>>> thread(
>>>     [1, 2, 3],
>>>     max,  # 3
>>>     str,  # '3'
>>>     len   # 1
>>> ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.