Skip to content

Instantly share code, notes, and snippets.

Timur Kheyfets tkheyfets

Block or report user

Report or block tkheyfets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View values.py
def function_name (dict):
for _, v in dict.items():
yield v
View omit.py
def function_name (dict, keys):
result = {}
for k, v in dict.items():
if k not in keys:
result[k] = v
return result
View group_by.py
def function_name (collection, k):
result = {}
for x in collection:
prop = x[k]
if prop not in result:
result[prop] = []
result[prop].append(x)
return result
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 invert.py
def function_name (dict):
result = {}
for k, v in dict.items():
result[v] = k
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 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
You can’t perform that action at this time.