After watching inspirational talk by Jim Weirich from 2012 schodlandjs on vimeo i came with slightly improved version rewritten with use of ES6 fat arrow syntax (it works in FF so why not).
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
/* | |
Eample for a blog post https://dawids-journal.vercel.app/journal/008-reduce | |
*/ | |
console.time('setup'); | |
let usersCount = 10; | |
// let usersCount = 100; | |
// let usersCount = 1_000; |
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
import { | |
assertEquals, | |
runIfMain, | |
test | |
} from "https://deno.land/std/testing/mod.ts"; | |
import { strip } from "./utils.ts"; | |
// import { verse, verses, song } from "./sandi99bottles.ts"; | |
import { verse, verses, song } from "./my99bottles.ts"; |
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 *fib () { | |
let n1 = 1, n2 = 1; | |
yield n1; | |
yield n2; | |
while (true) { | |
yield n1 + n2; | |
[n1, n2] = [n2, n1 + n2]; | |
} | |
} |