Skip to content

Instantly share code, notes, and snippets.

@e-mihaylin
Last active October 3, 2018 11:47
Show Gist options
  • Save e-mihaylin/fed58b0bdcf698a2438b40c2128179ec to your computer and use it in GitHub Desktop.
Save e-mihaylin/fed58b0bdcf698a2438b40c2128179ec to your computer and use it in GitHub Desktop.
const add = n => {
const f = x => add(n + x);
f.valueOf = () => n;
return f;
}
// Other Variants:
function add(n) {
var f = function(x) { return add(n+x); };
f.valueOf = function() { return n; };
return f;
}
function add(n){
var fn = function(x){ return add(n+x); }
fn.toString = function(){ return n; }
return fn;
}
function add(n) {
var next = add.bind(n += this | 0);
next.valueOf = function() { return n; };
return next;
}
function add(n){
function monad(m){return add(n+m)}
monad.valueOf = function valueOf(){return n};
return monad;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment