Files
30-seconds-of-code/snippets/curry.md
Angelos Chalaris 0f36c17995 Update explanations
Update explanation in digitize
Update explanation in delay
Update explanation in curry
Update explanation in compose_right
Update explanation in compose
2020-01-03 13:08:00 +02:00

393 B

title, tags
title tags
curry function,intermediate

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) # 30