Let's say I have a HOF
def some_func(lst):
def func(args):
if args[0]=='compute':
return sum(lst)
elif args[0]=='add':
XXXXX #Return a new HOF with the 2 sub HOF input parameters added together.
return func
x1=some_func([1,2,3])
x2=some_func([2,3,4])
One of the input *args for HOF is ('add', another_hof)
, which require the HOF to add another HOF parameter and return a HOF with added parameter.
example:
x3=x1('add',x2)
x4=some_func([3,5,7])
Then,
x3 should equal x4.
test_case:
x1=some_func([1,2,3])
x2=some_func([2,3,4])
x1('compute')=6
x2('compute')=9
x3=x1('add',x2)
x3('compute')=15
When I am doingx HOF the ('add,x2) for x1 function, is possible me to know the x2' input parameter [2,3,4] inside the function func(*args)?