Iterating over two-dimensional arrays
-
Why does the following program run into an error ("Unknown type: 4"),
array small[2] array big[3] for i = 0 to len(small) loop small[i] = big repeat counter = 0 for i = 0 to len(small) loop for j = 0 to len(big) loop small[i][j] = 1 counter += 1 print(counter, ": ", small, "\n") update() sleep(1) repeat repeat
while this one does not?:
array small[2] array big[3] for i = 0 to len(big) loop big[i] = small repeat counter = 0 for i = 0 to len(big) loop for j = 0 to len(small) loop big[i][j] = 1 counter += 1 print(counter, ": ", big, "\n") update() sleep(1) repeat repeat
-
Is there a line number where it breaks?
Am I missing something or is it identical except for array variable names?
-
@MikeDX It gets to line 13 two times, but I get the error the third time.
The difference is between (i) a short array with long arrays as elements, and (ii) a long array with short arrays as elements. The first kind gets the error message.
-
This is definitely a bug and I shall go file it in our issue tracker. Thanks for pointing it out (and the code!)