- Disgusting performance. Implementation based on recursive algorithms has done its job. Stack overflow problem.
- Modern javascript provides many cool features to implement infinite mathematical objects with a finite data structure. For instance, iterators, generator, closure.
// generator
function* nats(n) {
while (true) yield n++;
}
// closure
function nats(n) {
return () => n++;
}
// iterator
function nats(n) {
return {
[Symbol.iterator]() { return this; },
next() {
return { done: false, value: n++ };
}
};
};
$ git clone ...
$ cd project
$ npm i
$ npm run test
That is great! For more details see: