Have you tried writing a combinator which does exactly that? Take a look at zip in python. On Feb 14, 2015 2:52 PM, "Brian Blakely" <anewpage.me...@gmail.com> wrote:
> Apologies if this isn't the correct forum for this, and please point me > the right way if not. > > The motivation is that it would be useful if one could tersely loop over > multiple iterators simultaneously. I think this could be accomplished with > a "for-of-and" syntax. > > Example: > > let temp = [80, 35, 20]; > > let cond = ['sunny', 'cloudy']; > > for(let [t, c] of temp and cond) { > console.log(t, c); > // first: 80 'sunny' > // second: 35 'cloudy' > // third: 20 undefined > } > > As above, this is useful when we have two separate but related data sets. > It becomes more powerful as the data sets become more complex. > > Example: > > let forecast1 = [ > { > "highTemp": "90", > "lowTemp": "70" > }, > { > "highTemp": "92", > "lowTemp": "82" > }, > // etc... > ]; > > let forecast2 = [ > { > "high": "85", > "low": "68", > "condition": "partiallycloudy" > }, > { > "high": "95", > "low": "80", > "condition": "sunny" > }, > // etc... > ]; > > for(let [f1, f2] of forecast1 and forecast2) { > console.log(average(f1.highTemp, f2.high)); > } > > Thanks for reading! > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss