Skip to content

Instantly share code, notes, and snippets.

@marchdown marchdown/
Created Nov 21, 2014

What would you like to do?
def comp2(f,g):
return lambda x: f(g(x))
def comp(*fs):
return reduce(comp2, fs)
def reduce(reducing_function, fs, initial_value=None):
fs = iter(fs)
v = if initial_value is None else initial_value
for f in fs:
v = reducing_function(v, f)
return v
def inc(x):
return x + 1
def double(x):
return x * 2
def droot(x):
while (len(str(x))>1):
x = sum(map(int, str(x)))
return x
def droot_(x):
while (len(str(x))>1):
x = sum(map(int, str(x)))
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.