All source code available on github
intArray = [2, 3, 4, 6, 5, 7] strArray = ['2', '3', '4', '6', '5', '7'] # square all elements of array print map(lambda x:x**2, intArray) # convert string array to int array print map(int, strArray) a = [1, 2, 3] b = [4, 5, 6] # sum two array elements by index print map(lambda x, y : x+y, a, b)
Output:
[4, 9, 16, 36, 25, 49] [2, 3, 4, 6, 5, 7] [5, 7, 9]
0 comments:
Post a Comment