Function Currying

Currying can create a new function by reducing an existing function’s argument list. In Python, currying is done by functools.partial: from functools import partial def foo(a,b): return a+b bar = partial(foo, a=1) # equivalent to: foo(a=1, b) bar(b=10) #11 = 1+10 bar(a=101, b=10) #111=101+10 Roughly partial does this: def partial(func, Read more…

CSP concurrent prime filter

CSP concurrent prime sieve the sieve of Eratosthenes is an ancient algorithm for finding all prime numbers up to any given limit. It does so by iteratively marking as composite (i.e., not prime) the multiples of each prime, starting with the first prime number, 2. The multiples of a given Read more…