Skip to content

Instantly share code, notes, and snippets.

View benoitgrelard's full-sized avatar

Benoît Grélard benoitgrelard

View GitHub Profile
function curry(fn) {
const numArgs = fn.length;
return function curriedFn(...args) {
if (args.length < numArgs) {
return (...args2) => curriedFn(...[...args, ...args2]);
}
return fn(...args);
}
@benoitgrelard
benoitgrelard / basic-fp-principles.js
Last active April 25, 2019 09:47
Basic FP principles
const animals = [
{ name: 'dog', mamal: true },
{ name: 'dolphin', mamal: true },
{ name: 'eagle', mamal: true },
{ name: 'elephant', mamal: true },
{ name: 'robin', mamal: true },
{ name: 'cat', mamal: true },
{ name: 'salmon', mamal: false },
];