Logo

index : curry

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/public/curry.git/html/curry.py blob: 5be455b886fdd1af2d07051982374bda6fc884e5 [raw] [clear marker]

        
0
1
2class Curry:
3 def __init__(self, func, args=None):
4 self.func = func
5 self.args = args or []
6
7 def __call__(self, arg):
8 return Curry(self.func, self.args + [arg])
9
10 def ret(self):
11 return self.func(*self.args)
12
13
14def sum_args(*args):
15 return sum(args)
16
17
18def curry_sum(arg):
19 return Curry(sum_args)(arg)
20
21
22print("Result:", curry_sum(1)(2)(3).ret())
23# 6
24
25print("Result:", curry_sum(1)(4)(5)(10).ret())
26# 20
27
28
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit