map()
Apply a function to each element of an array and return a new array.
Implementation
Args: array: The array to map func: The function to apply to each element Returns: A new array with the results of applying func to each element
Example
map([1, 2, 3], lambda x: x * 2)
Expected output: [2, 4, 6]
Source Code
def map(array: List[T], func: Callable[[T], U]) -> List[U]:
return [func(x) for x in array]