Skip to content

Instantly share code, notes, and snippets.

View DrBoolean's full-sized avatar

Brian Lonsdorf DrBoolean

View GitHub Profile
@DrBoolean
DrBoolean / d4.js
Created October 6, 2015 18:04
Debug_4
f2.toString = function() {
return fx.toString()+'('+args.join(', ')+')';
}
@DrBoolean
DrBoolean / d5.js
Created October 6, 2015 18:05
Debug5
console.log(add)
// function f1() {
// var args = Array.prototype.slice.call(arguments, 0);
// if (args.length >= arity) return fx.apply(null, args);
//
// function f2() {
// return f1.apply(null, args.concat(Array.prototype.slice.call(arguments, 0)));
// }
// return f2;
// };
@DrBoolean
DrBoolean / d6.js
Created October 6, 2015 18:08
Debug6
console.log(inc)
// function add(x,y){ return x + y }(1)
@DrBoolean
DrBoolean / d8.js
Last active October 6, 2015 18:11
D8
f1.toString = function() { return fx.toString(); }
console.log(add)
// function add(x, y){ return x + y }
var incAll = map(inc);
console.log(incAll)
// function map(f, xs){ return xs.map(f) }(function add(x, y){ return x + y }(1))
function fToString(f) {
return f.name ? f.name : f.toString();
}
console.log(incAll)
// map(add(1))
function curry(fx) {
var arity = fx.length;
function f1() {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length >= arity) return fx.apply(null, args);
function f2() {
return f1.apply(null, args.concat(Array.prototype.slice.call(arguments, 0)));
}
var compose = function() {
var fns = arguments;
function f(result) {
for (var i = fns.length - 1; i > -1; i--) {
result = fns[i].call(this, result);
}
return result;
};