I\'m reading through the Python documentation to really get in depth with the Python language and came across the filter and map functions. I have used filter before, but never
filter(function, iterable) function (pointer, like in C) return boolean type
map(function, iterable) function (pointer, like in C) return e.g. int
def filterFunc(x):
if x & 1 == 0:
return False
return True
def squareFunc(x):
return x ** 2
def main():
nums = [5, 2, 9, 4, 34, 23, 66]
odds = list(filter(filterFunc, nums)) # filter(function, iterable)
print(odds)
square = list(map(squareFunc, nums)) # map(function, iterable)
print(square)
if __name__ == '__main__':
main()