Skip to content

Instantly share code, notes, and snippets.

@alinz
Created March 17, 2016 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alinz/bf4fb4ff73affaebeda4 to your computer and use it in GitHub Desktop.
Save alinz/bf4fb4ff73affaebeda4 to your computer and use it in GitHub Desktop.
const fp_delta = () => {
let p = null;
return (v) => {
const t = p == null ? v : p;
p = v;
return v - t;
};
};
const fp_min = (min) => (v) => v < min? min : v;
const fp_max = (max) => (v) => v > max? max : v;
const fp_mul = (val) => (v) => val * v;
const fp_sumStartWith = (v) => {
let t = v;
return (v) => {
t += v;
return t;
};
};
const compose = (...args) => (v) => args.reduce((a, c) => c(a), v);
const ali = compose(fp_min(0), fp_delta(), fp_mul(-1), fp_sumStartWith(55), fp_min(0), fp_max(55));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment