t516.py 374 B

123456789101112131415161718192021222324
  1. lst = [3, 6, 2, 1, 0]
  2. lst2 = [1, 2]
  3. print map(bool, lst)
  4. def outer():
  5. def inner(item):
  6. return 2 * item
  7. print map(inner, lst)
  8. outer()
  9. print map(None, lst, lst2)
  10. #filter with builtin functions
  11. print filter(bool, [0,1,"",False,42,[1]])
  12. #reduce with global variables
  13. adder = 100
  14. def add(x, y):
  15. return x + y + adder
  16. print reduce(add, [3, -7, 1], 100)