Skip to content

Instantly share code, notes, and snippets.

@sexwithsatan
Created January 6, 2021 14:58
Show Gist options
  • Save sexwithsatan/61639d39457d721a017ea35a0c31d7e8 to your computer and use it in GitHub Desktop.
Save sexwithsatan/61639d39457d721a017ea35a0c31d7e8 to your computer and use it in GitHub Desktop.
function* fibonacci([x, y], a, b) {
yield [x, y]
yield [x + 2*b - 3*a, y + 4*a - 2*b]
yield [x + a, y + a]
yield [x + 2*b - a, y + b - a]
yield [x + a + b, y - b + a]
yield [x + 2*a, y - (a + b)]
yield [x, y - 2*b]
yield [x - 2*b, y - (2*b - a)
yield* fibonacci([x - (2*b + a), y + a], 2*a + 3*b, 3*a + 5*b)
}
function* take(n, g) {
for (const _ of Array.from({length: n})) {
const {value, done} = g.next()
if (done) {
return
}
yield value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment