September 2017
Intermediate to advanced
216 pages
6h 8m
English
The zipping methods that we've looked at so far have all been called on lists. If you want to lazily zip lists together, you have to use a sequence, as follows:
names .toSeq() .zipWith( (...maps) => Map().merge(...maps), roles, ages ) .forEach(v => console.log('lazy zipWith', v.toJS())); // -> lazy zipWith { name: 'Jeremy', role: 'Engineer', age: 34 } // -> lazy zipWith { name: 'Garry', role: 'Designer', age: 23 } // -> lazy zipWith { name: 'Katie', role: 'Programmer', age: 36 }
You don't have to convert each of your lists to sequences in order to lazy zip them together. By calling toSeq() on the names list just before calling zipWith(), you're zipping together one map at a time as it's fed into the forEach() side-effect. Now ...
Read now
Unlock full access