Jason Orendorff (2014-08-11T14:14:57.000Z)
On Mon, Aug 11, 2014 at 8:49 AM, Andy Wingo <wingo at igalia.com> wrote:
> Turns out, yes: you can do it by constructing a graph of combinators,
> with normal method syntax.  So you can do:
>
>   var sequence = iterable.lazy().if(somePredicate)
>
> where lazy and if might be:
>
>   Iterable.prototype.lazy = function* () {
>     for (var x of this) yield x;
>   }
>   Iterable.prototype.if = function* (pred) {
>     for (var x of this) if pred(x) yield x;
>   }

Dave Herman put together a repository showing a real program, adapted
from array comprehensions:
  https://github.com/dherman/sudoku/blob/master/solver.pythonic.js
to using methods called .lazy(), .concat(), .map(), .filter(), and .flatMap():
  https://github.com/dherman/sudoku/blob/master/solver.methods.js
but I don't understand what's going on there. Where are these methods
defined? Is it intended that .map() and .flatMap() will be defined on
all iterables?

If so, how? Didn't the committee also decide not to give Iterables or
Iterators a common prototype, or define these methods as part of the
Iterator or Iterable interface?

-j
domenic at domenicdenicola.com (2014-08-18T18:38:56.750Z)
On Mon, Aug 11, 2014 at 8:49 AM, Andy Wingo <wingo at igalia.com> wrote:
> Turns out, yes: you can do it by constructing a graph of combinators,
> with normal method syntax.

Dave Herman put together a repository showing a real program, adapted
from array comprehensions:
  https://github.com/dherman/sudoku/blob/master/solver.pythonic.js
to using methods called .lazy(), .concat(), .map(), .filter(), and .flatMap():
  https://github.com/dherman/sudoku/blob/master/solver.methods.js
but I don't understand what's going on there. Where are these methods
defined? Is it intended that .map() and .flatMap() will be defined on
all iterables?

If so, how? Didn't the committee also decide not to give Iterables or
Iterators a common prototype, or define these methods as part of the
Iterator or Iterable interface?