On Tue, Jul 25, 2000 at 03:28:32PM -0400, Eric S. Raymond wrote: >[x**2 for x in filter(isprime, range(1, 99)] ... >filter, zip, product, and lambda are good enough to cover anything the >presently proposed comprehension syntax can handle. ... but not so elegantly, if the filter needs variables from the current scope. Consider removing all numbers in that range that are a multiple of a variable 'n'; you'd have to write: [x**2 for x in filter(lambda x, number = n: (x%n)!=0, range(1,99)) ] This uses the default argument hack to pass the value of 'n' into the scope of the lambda-created function as the parameter 'number'. Icky... I'd rather see extra syntax than more use of this kludge! --amk
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4