Implementation and Sub-specifications
Please hover over different parts of the implementation to see the corresponding sub-specifications.
import functools
import operator
def f(i1, i2):
return g1(i1, operator.sub, i2)
f([10, 11, 8], [1, 7, 5]) = [9, 4, 3]
def g1(i1, i2, i3):
def aux1(i4):
return i2(g2(i4, i1), g2(i4, i3))
return list(map(aux1, range(g3(i1))))
g1([10, 11, 8], operator.sub, [1, 7, 5]) = [9, 4, 3]
def g2(i1, i2):
def aux2(i3, i4):
return i3[1:]
return functools.reduce(aux2, range(i1), i2)[0]
g2(0, [10, 11, 8]) - g2(0, [1, 7, 5]) = 9
g2(1, [10, 11, 8]) - g2(1, [1, 7, 5]) = 4
g2(2, [10, 11, 8]) - g2(2, [1, 7, 5]) = 3
def g3(i1):
def aux3(i2, i3):
return i2+1
return functools.reduce(aux3, i1, 0)
g3([10, 11, 8]) = 3