Skip to content

Instantly share code, notes, and snippets.

Avatar
🤔

Timur Kheyfets tkheyfets

🤔
View GitHub Profile
View es6_insert.js
const insert = (item, index, array) =>
[...array.slice(0, index),
...item,
...array.slice(index, array.length)];
View sorted_union.js
const sortedUnion = (a, b) => {
const c = {};
[...a, ...b].forEach(i => c[i] = i);
return Object.keys(c);
};
View es6_remove.js
const remove = (index, array) =>
[...array.slice(0, index),
...array.slice(index + 1, array.length)];
View debounce.js
function debounce(fn, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) fn.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
View clone.js
function clone(obj) { return Object.create(obj); }
View map.py
def function_name (iterable, f):
for x in iterable:
yield f(x)
View filter.py
def function_name (iterable, f):
for x in iterable:
if f(x): yield x
View find.py
def function_name (iterable, f):
result = None
for x in iterable:
if f(x):
result = x
break
return result
View reverse.py
def function_name (iterable):
return iterable[::-1]
View any.py
def function_name (iterable, f):
result = False
for x in iterable:
if f(x):
result = True
break
return result