JSFiddle - React, Tailwind, and code Playground
JavaScript
var multiply, back, myCalc, multiplyPi, bindState, test, slice$ = [].slice;
multiply = curry$(function(a, b, history){
return [a * b, [a + " * " + b].concat(history)];
});
back = function(arg$){
var top, history;
top = arg$[0], history = slice$.call(arg$, 1);
return [top, history];
};
myCalc = [];
multiplyPi = multiply(Math.PI);
bindState = curry$(function(g, f, s){
var ref$, a, t;
ref$ = g(s), a = ref$[0], t = ref$[1];
return f(a)(t);
});
test = bindState(multiplyPi(1), function(prod){
alert(prod);
return back;
});
alert(test(myCalc)[0]);
function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
};
return _curry();
}