parallel iteration in lua

Viewed 1862

I would like to for-loop through multiple tables in parallel in Lua. I could just do:

for i in range(#table1)
  pprint(table1[i])
  pprint(table2[i])
end

But I'd rather something like python's zip:

for elem1, elem2 in zip(table1, table2):
  pprint(elem1)
  pprint(elem2)
end

Is there such a thing in standard Lua (or at least in whatever comes packaged with torch?).

2 Answers
Related