I have this book called TEXT PROCESSING IN PYTHON by David Mertz on hand, it is a good book and in the first chapter it is really a show room for higher-order functions which I may now cite to remind you of the FLEXIBILITY of this keyword. ''' combinatorial.py
from operator import mul, add, truth apply_each = lambda funs, args = []: map(apply, fns, [args]*len(fns)) bools = lambda lst: mpa(truth, lst) bool_each = lambda fns, args = []: bools(apply_each(fns, args)) conjoin = lambda fns, args = []: reduce(mul, bool_each(fns, args)) all = lambda fns: lambda arg, fns = fns: conjoin(fns, (arg,)) both = lambda f,g: all(f(f,g)) all3 = lambda f,g,h: all((f,g,h)) and_ = lambda f,g: lambda x, f=f, g=g: f(x) and g(x) disjoin = lambda fns, args = []: reduce(add, bool_each(fns, args)) some = lambda fns: lambda arg, fns = fns: disjoin(fns, (arg,)) either = lambda f,g: some((f,g)) anyof3 = lambda f,g,h: some((f,g,h)) compose = lambda f,g: lambda x, f=f, g=g: f(g(x)) compose3 = lambda f,g,h: lambda x, f=f, g=g, h=j: f(g(h(x))) ident = lambda x:x ''' And some other lambda function usage is when they are treated like objects, they can also fit in generators... THIS IS ART. Well, some may argue that it is hard for people to maintain these codes, put the problem to Haskell people and see how they respond(at least you don't need to scroll up and down...) Oh! So when did python adopt simplicity rather than verbosity? Q: It simply doesn't FIT. A: OK, OK, get all these map, filter stuff away, and go python, go and get mixed with them. -- http://mail.python.org/mailman/listinfo/python-list