Skip to content

Generators

Arthur Guiot edited this page May 20, 2018 · 1 revision
const gen = t.collatz(10)

gen.next().value // 5
gen.next().value // 16
gen.next().value // 8
gen.next().value // 4
gen.next().value // 2
gen.next().value // 1
const gen = t.fibonacci()

gen.next().value // 0
gen.next().value // 1
gen.next().value // 1
gen.next().value // 2
...
const gen = t.sieve()

gen.next().value // 2
gen.next().value // 3
gen.next().value // 5
gen.next().value // 7
...
Clone this wiki locally