jussi-kalliokoski / trine

A utility library for modern JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Change union, intersection and difference to take an iterator of iterators

jussi-kalliokoski opened this issue · comments

Currently the operations take one iterator as this and another as second. This breaks the "data as this" idea, and is also poorly extensible to support more than two iterators.

I propose changing them to take an iterarator of iterators instead:

[[1,2,3,4,6,7], [2,4,6]]::difference(sub) // yields 1, 3, 7

Then we'd throw when more than two iterators are provided for now. This is also how I'd like to do other set operations, such as cartesian product and concatenation.

WDYT?

@jussi-kalliokoski, I think thats a good idea, i've started implementing zip the same way you proposed here...