3 ms·
Or, with a little setup, the Closure snippet (def s (range 0 10)) (reduce + (map inc (filter even? s))) can be turned into Python's from functool
by azag0 9y ago
Or, with a little setup, the Closure snippet
(def s (range 0 10))
(reduce + (map inc (filter even? s)))
can be turned into Python's
from functools import reduce
from operator import add
def inc(x): return x + 1
def even(x): return x % 2 == 0
s = range(0, 10)
reduce(add, map(inc, filter(even, s)))
Everything's lazy in there. It's just... not very Pythonic.