Created
March 17, 2016 13:28
-
-
Save alinz/bf4fb4ff73affaebeda4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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