This file contains 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 characters
var memoizer = function(memo, func) { | |
var recur = function(n) { | |
var result = memo[n]; | |
if (typeof result !== 'number') { | |
result = func(recur, n); | |
memo[n] = result; | |
} | |
return result; | |
}; | |
return recur; |
This file contains 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 characters
for (var i = 1; i <= 100; ++i) { | |
var f = i % 3 === 0, b = i % 5 === 0; | |
console.log(f ? b ? 'FizzBuzz' : 'Fizz' : b ? 'Buzz' : i); | |
} |
This file contains 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 characters
var isInteger = function(x) { return (x ^ 0) === x; }; | |
function isPrime(number) { | |
if (typeof number !== 'number' || !isInteger(number)) { | |
// Alternatively you can throw an error. | |
return false; | |
} | |
if (number < 2) { | |
return false; |
This file contains 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 characters
(function() { | |
var SpotifySearch = window.SpotifySearch = function() { | |
}; | |
}).call(this); |
This file contains 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 characters
// When.js | |
// TJ Eastmond <[email protected]>, SpiteShow | |
// Simple Underscore.js Mixin that runs the first function until | |
// it returns true, then runs the second | |
(function() { | |
// Pass in two functions. The first is checked until it returns true, then the second is run | |
var when = function(truthy, func) { | |
// Just making sure we were passed functions... |
NewerOlder