Javascript equivalent of Python’s zip function

2016 update: Here’s a snazzier Ecmascript 6 version: zip= rows=>rows[0].map((_,c)=>rows.map(row=>row[c])) Illustration equiv. to Python{zip(*args)}: > zip([[‘row0col0’, ‘row0col1’, ‘row0col2’], [‘row1col0’, ‘row1col1’, ‘row1col2’]]); [[“row0col0″,”row1col0”], [“row0col1″,”row1col1”], [“row0col2″,”row1col2”]] (and FizzyTea points out that ES6 has variadic argument syntax, so the following function definition will act like python, but see below for disclaimer… this will not be its own inverse … Read more

Spanning repeatable keys

1> L_tup = [ 1> {“Caerus1”, “Ramses Refiner”}, 1> {“Caerus1”, “Jupiter Refiner”}, 1> {“Caerus1”, “Jupiter Other”}, 1> {“Caerus1”, “Trader 13”}, 1> {“Caerus1”, “Cathode Supplier 4”}, 1> {“Dionysus3”, “Cathode Supplier 4”}, 1> {“Dionysus3”, “Ramses Refiner”}, 1> {“Dionysus3”, “Trader 13”}, 1> {“Dionysus3”, “Jupiter Refiner”}, 1> {“Dionysus3”, “Jupiter Other”}, 1> {“Prometheus2”, “Jupiter Other”}, 1> {“Prometheus2”, “Ramses Refiner”}, 1> … Read more