Quick actions

cmd+k|ctrl+k

Navigation

Languages

curry function

Snippet info

Language

Python

Visibility

public

Author

aco

Created

2024-10-16T00:53:33.899805Z

Updated

2024-10-16T01:29:24.595693Z

print('curry sample1')
def f(a1, a2, a3):
    return a1 * a2 * a3
    
def f1(a1):
    def f2(a2):
        def f3(a3):
            return f(a1, a2, a3)
        return f3
    return f2
for i in range(1, 10):
    print(f(i, i+1, i+2), f1(i)(i+1)(i+2))


  
print('curry sample2')
def f(state_tax, city_tax, income):
    return (state_tax * income) + (city_tax * income)
    
def f1(state_tax=0.15):
    def f2(city_tax=0.1):
        def f3(income):
            return f(state_tax, city_tax, income)
        return f3
    return f2
print(f1()()(100))
INFO