View reject.py
def function_name (iterable, f):
for x in iterable:
if not f(x): yield x
View reduce_right.py
def function_name (iterable, f, i = None):
result = i
for x in iterable[::-1]:
result = f(result, x)
return result
View group_by.py
def function_name (iterable, k):
result = {}
for x in iterable:
if x[k] not in result:
result[x[k]] = []
result[x[k]].append(x)
return result
View invert.py
def function_name (dict):
result = {}
for k, v in dict.items():
result[v] = k
return result
View omit.py
def function_name (dict, iterable):
result = {}
for k, v in dict.items():
if k not in iterable:
result[k] = v
return result
View reduce.py
def function_name (iterable, f, i = None):
result = i
for x in iterable:
result = f(result, x)
return result
View values.py
def function_name (dict):
for k, v in dict.items():
yield v
View keys.py
def function_name (dict):
for k in dict:
yield k
View memoize.py
def function_name (f):
dict = {}
def inner_function(x):
if x not in dict:
dict[x] = f(x)
return dict[x]
return inner_function
View last.py
def function_name (iterable):
if len(iterable) > 0:
return iterable[-1]
else:
return None