Is this a good use for lambda
Steven Bethard
steven.bethard at gmail.com
Tue Dec 21 05:50:21 EST 2004
More information about the Python-list mailing list
Tue Dec 21 05:50:21 EST 2004
- Previous message (by thread): Is this a good use for lambda
- Next message (by thread): Is this a good use for lambda
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan wrote: > def compose(list_of_functions): > application_order = reversed(list_of_functions) > def composed(x): > for f in application_order: > x = f(x) > return x > return composed reversed returns an iterator to the list in reverse order, not a copy of the list: >>> lst = range(10) >>> riter = reversed(lst) >>> list(riter) [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] >>> list(riter) [] so you either need to call reversed each time in 'composed' or copy the list and call reverse. Steve
- Previous message (by thread): Is this a good use for lambda
- Next message (by thread): Is this a good use for lambda
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list