Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

generator-examples

Some examples of generator usings.

Lazy Sieve of Eratosthenes

https://github.com/lukesolo/generator-examples/blob/master/lib/eratosthenes.js

In this implementation you don't have to specify the size of an array. Next prime is being generated lazily, so you can work with primes sequence in more flexible way.

For example:

// All primes greater than 50 and below 100
console.log(...compose(takeWhile(x => x < 100), filter(x => x > 50), erath)());
// 53 59 61 67 71 73 79 83 89 97

// First 10 primes
console.log(...compose(take(10), erath)());
// 2 3 5 7 11 13 17 19 23 29

About

Some examples of generator usings.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages