Skip to content

Instantly share code, notes, and snippets.

@FuruNov
Created March 29, 2023 12:39
Show Gist options
  • Select an option

  • Save FuruNov/6b1d7f624a3737299ef9cc945eb7eedb to your computer and use it in GitHub Desktop.

Select an option

Save FuruNov/6b1d7f624a3737299ef9cc945eb7eedb to your computer and use it in GitHub Desktop.
カリー化するデコレータ
def curry(func):
def curried(*args):
if len(args) == func.__code__.co_argcount:
return func(*args)
return lambda x: curried(*args, x)
return curried
@curry
def add(x, y):
return x + y
print(add(1)(2)) # 3 と出力される
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment