Last active
August 29, 2015 14:16
-
-
Save fuzzyalej/cf3870103cd28206f780 to your computer and use it in GitHub Desktop.
Revisions
-
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -206,3 +206,10 @@ function fork(predicate, f, g) { return g.apply(null, arguments); }; } function serial(f, g) { return function() { f.apply(null, arguments); g.apply(null, arguments); }; } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -197,3 +197,12 @@ function curry(fn) { } return stillCurrying([]); } function fork(predicate, f, g) { return function() { if(predicate.apply(null, arguments)) return f.apply(null, arguments); else return g.apply(null, arguments); }; } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -182,3 +182,18 @@ function partial(fn) { }; } function curry(fn) { n = fn.length; function stillCurrying(prev) { return function(arg) { var args = prev.concat(arg); if (args.length < n) { return stillCurrying(args); } else { return fn.apply(this, args); } }; } return stillCurrying([]); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -181,4 +181,4 @@ function partial(fn) { return fn.apply(this, args.concat(args2)); }; } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -174,3 +174,11 @@ function memoize(fn) { }; } function partial(fn) { var args = Array.prototype.slice.call(arguments, 1); return function() { var args2 = Array.prototype.slice.call(arguments); return fn.apply(this, args.concat(args2)); }; } // This is the simpler one, we can create partial functions to fix middle or end arguments! -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -164,4 +164,13 @@ function groupBy(list, fn) { recurr(groups, list.next, fn); return groups; }({}, list, fn)); } function memoize(fn) { var cache = {}; return function(argument) { cache[argument] = cache[argument] || fn(argument); return cache[argument]; }; } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 0 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -81,13 +81,6 @@ function append(list1, list2) { return cons(first(list1), append(rest(list1), list2)); } function reverse(list) { if(not(listp(list))) return null; if(rest(list) === null) return cell(first(list)); //! -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -140,12 +140,6 @@ function every(list, fn) { }); } function any(list, fn) { return reduce(list, false, function(acc, el) { return acc || fn(el); -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 12 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -166,3 +166,15 @@ function partition(list, fn) { return [group1, group2]; }([], [], list, fn)); } function groupBy(list, fn) { return(function recurr(groups, list, fn){ result = fn(list.value); (groups[result] = groups[result] || []).push(list.value); if(list.next === null) return groups; recurr(groups, list.next, fn); return groups; }({}, list, fn)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -151,3 +151,18 @@ function any(list, fn) { return acc || fn(el); }); } function partition(list, fn) { return(function recurr(group1, group2, list, fn){ if(fn(list.value)) { group1.push(list.value); } else { group2.push(list.value); } if(list.next === null) return; recurr(group1, group2, list.next, fn); return [group1, group2]; }([], [], list, fn)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -146,3 +146,8 @@ function every(list, fn) { }); } function any(list, fn) { return reduce(list, false, function(acc, el) { return acc || fn(el); }); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -140,3 +140,9 @@ function every(list, fn) { }); } function every(list, fn) { return reduce(list, true, function(acc, el) { return acc && fn(el); }); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -134,4 +134,9 @@ function reduceRight(list, initial_value, fn) { } var foldR = reduceRight; function every(list, fn) { return reduce(list, true, function(acc, el) { return acc && fn(el); }); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -128,5 +128,10 @@ function reduce(list, initial_value, fn) { } var fold = reduce; function reduceRight(list, initial_value, fn) { if(list === null) return initial_value; return fn(reduceRight(rest(list), initial_value, fn), first(list)); } var foldR = reduceRight; -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -122,5 +122,11 @@ function find(list, predicatefn) { return first(filter(list, predicatefn)); } function reduce(list, initial_value, fn) { if(list === null) return initial_value; return reduce(rest(list), fn(initial_value, first(list)), fn); } var fold = reduce; -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -118,6 +118,9 @@ function count(predicate, list) { return length(filter(list, predicate)); } function find(list, predicatefn) { return first(filter(list, predicatefn)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -114,6 +114,10 @@ function filter(list, predicatefn) { } } function count(predicate, list) { return length(filter(list, predicate)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -107,8 +107,11 @@ function map(list, fn) { function filter(list, predicatefn) { if(not(listp(list))) return null; if(predicatefn(first(list))) { return cons(first(list), filter(rest(list), predicatefn)); } else { return filter(rest(list), predicatefn); } } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -105,6 +105,12 @@ function map(list, fn) { return cons(fn(first(list)), map(rest(list), fn)); } function filter(list, predicatefn) { if(not(listp(list))) return null; if(predicatefn(first(list))) return cons(first(list), filter(rest(list), predicatefn)); return filter(rest(list), predicatefn); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -100,5 +100,11 @@ function remove(value, list) { return cons(first(list), remove(value, rest(list))); } function map(list, fn) { if(not(listp(list))) return null; return cons(fn(first(list)), map(rest(list), fn)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -94,5 +94,11 @@ function reverse(list) { return append(reverse(rest(list)), cell(first(list))); } function remove(value, list) { if(not(listp(list))) return null; if(first(list) === value) return remove(value, rest(list)); return cons(first(list), remove(value, rest(list))); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -88,6 +88,11 @@ function append(list1, list2) { return cons(first(list1), append(rest(list1), list2)); } function reverse(list) { if(not(listp(list))) return null; if(rest(list) === null) return cell(first(list)); //! return append(reverse(rest(list)), cell(first(list))); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -81,4 +81,13 @@ function append(list1, list2) { return cons(first(list1), append(rest(list1), list2)); } function append(list1, list2) { if(not(listp(list1)) && not(listp(list2))) return null; if(rest(list1) === null) { return cons(first(list1), list2); } return cons(first(list1), append(rest(list1), list2)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -73,3 +73,12 @@ function print(list) { if(listp(first(list))) return '(' + print(first(list)) + '' + print(rest(list)) + ')'; return ('' + first(list) + ' ' + print(rest(list))); } function append(list1, list2) { if(not(listp(list1)) && not(listp(list2))) return null; if(rest(list1) === null) { return cons(first(list1), list2); } return cons(first(list1), append(rest(list1), list2)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -68,4 +68,8 @@ function predicatep(input) { return input === true || input === false; } function not(predicate) { return !!!predicate; } function print(list) { if(list === null) return ''; if(listp(first(list))) return '(' + print(first(list)) + '' + print(rest(list)) + ')'; return ('' + first(list) + ' ' + print(rest(list))); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -53,7 +53,19 @@ function nth(position, list) { return nth(position-1, rest(list)); } function listp(input) { if(input === null) return null; return (typeof(input) === 'object') && input.hasOwnProperty('value') && input.hasOwnProperty('next'); } function atomp(input) { return !listp(input); } function nullp(input) { return input === null; } function predicatep(input) { return input === true || input === false; } function not(predicate) { return !!!predicate; } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -53,4 +53,7 @@ function nth(position, list) { return nth(position-1, rest(list)); } function print(list) { if(list === null) return ''; return ('' + first(list) + ' ' + print(rest(list))); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -38,8 +38,19 @@ function last(list) { return last(rest(list)); } function length(list) { if(list === null) return 0; return 1 + length(rest(list)); } function replace_first(value, list) { return cons(value, rest(list)); } function nth(position, list) { if(position > length(list) || position < 1) return null; if(position === 1) return first(list); return nth(position-1, rest(list)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,4 +36,10 @@ var tail = rest; function last(list) { if(rest(list) === null) return first(list); return last(rest(list)); } function length(list) { if(list === null) return 0; return 1 + length(rest(list)); } -
Alejandro Andrés revised this gist
Feb 27, 2015 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -31,4 +31,9 @@ function rest(list) { return list.next; } var cdr = rest; var tail = rest; function last(list) { if(rest(list) === null) return first(list); return last(rest(list)); }
NewerOlder