svghmi/pythonic.js
changeset 3594 30f7eade322f
parent 3485 5f417d3c2d03
equal deleted inserted replaced
3593:122b1094b8e6 3594:30f7eade322f
   163         }
   163         }
   164     });
   164     });
   165 }
   165 }
   166 
   166 
   167 const _zip = longest => (...iterables) => {
   167 const _zip = longest => (...iterables) => {
   168     if (iterables.length < 2) {
   168     if (iterables.length == 0) {
   169         throw new TypeError("zip takes 2 iterables at least, "+iterables.length+" given");
   169         // works starting with 1 iterable
       
   170         // [a,b,c] -> [[a],[b],[c]]
       
   171         // [a,b,c],[d,e,f] -> [[a,d],[b,e],[c,f]]
       
   172         throw new TypeError("zip takes 1 iterables at least, "+iterables.length+" given");
   170     }
   173     }
   171 
   174 
   172     return new Iterator(function * () {
   175     return new Iterator(function * () {
   173         const iterators = iterables.map(iterable => Iterator.fromIterable(iterable));
   176         const iterators = iterables.map(iterable => Iterator.fromIterable(iterable));
   174         while (true) {
   177         while (true) {