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 requestPromise; | |
function getCurrentState() { | |
if (requestPromise) return requestPromise; | |
requestPromise = ajaxRequestReturningPromise('GET', '/state.json'); | |
reqrequestPromise.then(function() { requestPromise = null }); | |
return requestPromise; | |
} | |
promise1 = getCurrentState() |
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
-- | The 'partition' function splits a list into sublists of length n. | |
partition :: Int -> [a] -> [[a]] | |
partition n xs = unfoldr step xs | |
where step :: [a] -> Maybe ([a], [a]) | |
step [] = Nothing | |
step ys = Just (take n ys, drop n ys) |
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
// If you return a value from the `initialize()` method, that value | |
// is returned when you instantiate the class using `new`. | |
// Here, we use this to make `singleton` a class that generates | |
// new classes. The singleton instance is protected by a closure. | |
JS.singleton = new JS.Class({ | |
initialize: function(name, parent, methods) { | |
var instance = null; | |
return new JS.Class(name, parent, { |