/sequence

Functional iterators

Primary LanguageJavaScriptMIT LicenseMIT

Purely functional iterators

Build Status Coverage Status GitHub license

Please keep in mind that:

  • 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++ };
    } 
  };
};

How to use

$ git clone ...
$ cd project
$ npm i
$ npm run test

I have more questions!

That is great! For more details see: