Closed claussI closed 9 years ago
See http://stackoverflow.com/questions/22015684/how-do-i-zip-two-arrays-in-javascript
To compute expressions involving the values of two arrays, it would be great to be able to join the two same-length arrays.
Example:
{ "publiPerYear": [ {"_id":"2007","value":538}, {"_id":"2008","value":577}, {"_id":"2009","value":611}, {"_id":"2010","value":548}, {"_id":"2011","value":567}, {"_id":"2012","value":608}], "citationsPerYear": [ {"_id":"2007","value":7681}, {"_id":"2008","value":5479}, {"_id":"2009","value":5043}, {"_id":"2010","value":3698}, {"_id":"2011","value":2927}, {"_id":"2012","value":2049}] }
We would like to divide citationsPerYear[i] by publiPerYear[i]:
citationsPerYear[i]
publiPerYear[i]
{ "zip": [ "citationsPerYear", "publiPerYear" ], "foreach": { "compute": "this.citationsPerYear / this.publiPerYear" } }
In this example, "zip": [ "citationsPerYear", "publiPerYear" ] should return:
"zip": [ "citationsPerYear", "publiPerYear" ]
[ {"_id":"2007","citationsPerYear":7681, "publiPerYear": 538}, {"_id":"2008","citationsPerYear":5479, "publiPerYear": 577}, {"_id":"2009","citationsPerYear":5043, "publiPerYear": 611}, {"_id":"2010","citationsPerYear":3698, "publiPerYear": 548}, {"_id":"2011","citationsPerYear":2927, "publiPerYear": 567}, {"_id":"2012","citationsPerYear":2049, "publiPerYear": 608}]
See http://stackoverflow.com/questions/22015684/how-do-i-zip-two-arrays-in-javascript
To compute expressions involving the values of two arrays, it would be great to be able to join the two same-length arrays.
Example:
We would like to divide
citationsPerYear[i]
bypubliPerYear[i]
:In this example,
"zip": [ "citationsPerYear", "publiPerYear" ]
should return: