September 2017
Intermediate to advanced
216 pages
6h 8m
English
The challenge with the preceding approach is that the collections that we're concatenating together could actually be indexed sequences, capable of evaluating lazily. If you concatenate them into a list, then you lose any benefit to lazy evaluation. Instead, you can call the concat() method on a sequence:
const mySeq1 = Range(1, 6) .filterNot((v) => { console.log('mySeq1', v); return v % 2; });const mySeq2 = Range(6, 11) .filterNot((v) => { console.log('mySeq2', v); return v % 2; });Seq() .concat(mySeq1, mySeq2) .forEach(v => console.log('result', v)); // -> mySeq1 1 // -> mySeq1 2 // -> result 2 // -> mySeq1 3 // -> mySeq1 4 // -> result 4 // -> mySeq1 5 // -> mySeq2 6 // -> result 6 // -> mySeq2 7 // -> mySeq2 ...Read now
Unlock full access