1 of 5

Iterator Sequencing

Stage 1 Update

Michael Ficarra • November 2023

2 of 5

goals

  • conveniently compose 2 iterators
  • conveniently compose 0 or more iterators
  • compose an infinite sequence of iterators
  • conveniently interleave other values among the iterators
  • discoverable/intuitive pattern

3 of 5

analysis & comparison

2

0+

infinite

interleave

discoverability

I.of(...) + I.p.flat()

good

excellent

with wrapper

not good

I.p.append(...)

excellent

no

no

with wrapper

excellent

I.from(...)

excellent

excellent

no

with wrapper

decent

I.concat(iters)

with wrapper

with wrapper

with wrapper

very good

4 of 5

champion's preference

  • variadic Iterator.from
    • for when you have a small number of iterators/iterables
  • Iterator.prototype.flat
    • for when you have an iterator/iterable of iterators/iterables

5 of 5

requesting feedback

is this a good way forward?