2013-01-15 | Paul Boddie | file changeset files shortlog | Added support for multiple class definitions in the same namespace with the same name. Made classes attribute users. |
paul@329 | 1 | #!/usr/bin/env python |
paul@329 | 2 | |
paul@329 | 3 | def make_add(x): |
paul@329 | 4 | return lambda a, b=x: a + b |
paul@329 | 5 | |
paul@329 | 6 | def g(f, x): |
paul@329 | 7 | return f(x) |
paul@329 | 8 | |
paul@329 | 9 | add_2 = make_add(2) |
paul@330 | 10 | add_3 = make_add(3) |
paul@330 | 11 | |
paul@329 | 12 | result_3 = add_2(1) |
paul@330 | 13 | result_4 = g(add_2, 2) |
paul@330 | 14 | |
paul@330 | 15 | result_5 = add_3(2) |
paul@330 | 16 | result_6 = g(add_3, 3) |
paul@329 | 17 | |
paul@329 | 18 | # vim: tabstop=4 expandtab shiftwidth=4 |