Develop myReduce

Develop a function by name myReduce which takes a collection and a function as arguments. Function should do the following:

  • Iterate through elements

  • Perform aggregation operation using the argument passed. Argument should have necessary arithmetic logic.

  • Return the aggregated result.

l = [1, 4, 6, 2, 5]
l[1:]
def myReduce(c, f):
    t = c[0]
    for e in c[1:]:
        t = f(t, e)
    return t
myReduce(l, lambda t, e: t + e)
myReduce(l, lambda t, e: t * e)
min(7, 5)
myReduce(l, lambda t, e: min(t, e))
myReduce(l, lambda t, e: max(t, e))