Skip to content

Instantly share code, notes, and snippets.

View jeremiahbiard's full-sized avatar

Jeremiah Biard jeremiahbiard

View GitHub Profile
@jeremiahbiard
jeremiahbiard / memoized factorial function
Created June 24, 2015 17:40
memoized factorial function
var f = [];
function factorial (n) {
if (n == 0 || n == 1)
return 1;
if (f[n] > 0)
return f[n];
return f[n] = factorial(n-1) * n;
}
@jeremiahbiard
jeremiahbiard / Symmetric Difference Bonfire
Created June 15, 2015 20:51
Solution to the symmetric difference bonfire. I love functional programming.
function complement(A, B) {
return A.filter(function(elem) { return B.indexOf(elem) == -1; });
}
function unique(arr) {
return arr.filter(function(elem, pos) {
return arr.indexOf(elem) == pos;
});
}
@jeremiahbiard
jeremiahbiard / gist:7d9e64149c87d876d95c
Created June 11, 2015 03:35
Map/Filter chaining javascript
return newReleases.filter(function(movie) {
return (movie.rating === 5.0);
}).map(function(movie) {
return movie.id;
});