How do I write a function that returns another function?

前端 未结 4 1778
悲&欢浪女
悲&欢浪女 2020-12-07 15:32

In Python, I\'d like to write a function make_cylinder_volume(r) which returns another function. That returned function should be callable with a parameter

4条回答
  •  误落风尘
    2020-12-07 15:49

    Just want to point out that you can do this with pymonad

     import pymonad 
    
     @pymonad.curry
     def add(a, b):
         return a + b
    
     add5 = add(5)
     add5(4)
     9
    

提交回复
热议问题