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
// Lazy Getters | |
/* What enables Tail Recursion Modulo Cons in Javascript is a thunk in Weak Head Normal Form. | |
An expression in weak head normal form has been evaluated to the outermost data constructor, | |
but contains sub-expressions that may not have been fully evaluated. In Javascript only thunks | |
can prevent sub-expressions from being immediately evaluated. */ | |
const cons = (head, tail) => ({head, tail}); | |
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
let cache = new Map(); | |
let pending = new Map(); | |
function fetchTextSync(url) { | |
if (cache.has(url)) { | |
return cache.get(url); | |
} | |
if (pending.has(url)) { | |
throw pending.get(url); | |
} |