I'm rewriting a piece of Python code for C and I'm stuck at a moment where the author used zip
function. Please consider the following:
def coords(step_size):
for dz in (-step_size / 2, step_size / 2):
for dx, dy in zip((-step_size / 2, step_size / 2, step_size / 2, -step_size / 2),
(step_size / 2, step_size / 2, -step_size / 2, -step_size / 2)):
yield dx, dy, dz
This function is called in a loop like so:
for dx, dy, dz in coords(step_size):
....
If my understanding is correct, zip
creates a tulpa iterator object by combining passed values and this function simply calculates the values for dx, dy,dz
, but I'm struggling to figure out what exactly happens here and how could I adapt it for C. Would appreciate your help greatly!
Thanks