I want a function named times(), in order to make:
times(func,2) equivalent to lambda x:func(func(x))
and times(func,5) equivalent to lambda x:func(func(func(func(func(x)))))
Is there such a tool in Python? What would the code looks like if I want to write it by myself?
Thanks!
I’d suggest to call this
power(), since this is actually thenth power of a function. There is no such thing in the standard library, but you can easily implement it yourself: