[Solved] how to implement map and reduce function from scratch as recursive function in python? [closed]


def map(func, values):
    rest = values[1:]
    if rest:
        yield from map(func, rest)
    else:
        yield func(values[0])

It’s a generator so you can iterate over it:

for result in map(int, '1234'):
    print(result + 10)

Gives:

11
12
13
14

4

solved how to implement map and reduce function from scratch as recursive function in python? [closed]