Consider the following series of functions:
def x(a):
if callable(a):
return lambda i: a(i)
else:
return a
then
def x(a):
def xx(b):
if callable(b):
return lambda i: a(b(i))
else:
return a(b)
return xx
then
def x(a):
def xx(b):
if callable(b):
def xxx(c):
if callable(c):
return lambda i: a(b(c(i)))
else:
return a(b(c))
return xxx
else:
return a(b)
return xx
and so on...
Two questions:
- how would you write a single recursive or iterative version of this that could handle cases of any depth?
- what would you call what this function x is doing?
The original post was in the category:
python
but I'm still in the process of migrating categories over.
The original post had 23 comments I'm in the process of migrating over.
There may be broken links to media on this page. I'm still in the process of migrating them over.