Mentioned in the chapter are many functions which take a sequence in the argument. Stepper examples show these with example arguments.


Functions of Sequences

A = ["part","cover","sit","blunder","of","is"]
B = (90,22,1,201,90,-40)
C = [False,True,True, False]
print sum(B)
print max(A), max(B)
print all(C), any(C)
print zip(B,A)
print zip(A,B)
print sorted(A)
print sorted(B)
print list(reversed(B))


The next three require a function as well as a sequence.


Built-in Functionals

def f(e):
  return e/2
def even(n):
  return (n%2)==0
def takelast(sofar,nextitem):
  return sofar+nextitem[-1]
a = map(f,[8,14,3,18,7])
b = filter(even,[8,14,3,18,7])
c = reduce(takelast,
      ['-->',"rat","also","zoo","boil"])