Start of main content
Curry function
Python, Function · Nov 2, 2020

Curries a function.
- Use
functools.partial()
to return a new partial object which behaves like fn
with the given arguments, args
, partially applied.
from functools import partial
def curry(fn, *args):
return partial(fn, *args)
add = lambda x, y: x + y
add10 = curry(add, 10)
add10(20)
More like this

Builds a list, using an iterator function and an initial seed value.
Python, Function · Nov 2, 2020

Mutable default arguments can trip up Python beginners and veterans alike. Here's a quick workaround to deal with them.
Python, Function · Feb 27, 2022

Performs left-to-right function composition.
Python, Function · Nov 2, 2020