how to get top N distinct elements from range?

bearophile bearophileHUGS at lycos.com
Fri Mar 8 17:24:00 PST 2013


> from sys import stdout
> def fun(x):
>     stdout.write("*")
>     return x
> list(filter(lambda x: True, map(fun, xrange(5))))

Sorry, I meant:


from itertools import imap, ifilter
from sys import stdout
def fun(x):
     stdout.write("*")
     return x
list(ifilter(lambda x: True, imap(fun, xrange(5))))


More information about the Digitalmars-d-learn mailing list