天天看点

如何实现Python中的map函数如何实现Python中的map函数

如何实现Python中的map函数

>>> def myMap(f,listA):
>>>     if listA == []:
>>>         return []
>>>     return [f(listA[])] + myMap(f,listA[:])
>>>
>>> def add(x):
>>>     return x+
>>>
>>> myMap(add,[,,])
>>> [,,]