4.3.3 Iterate of the Antik manual has this code example:
(defparameter m1 #m(1 2 3 ^ 0 6 8))
(iter:iter (iter:for e :matrix-element m1) (princ e) (princ " "))
;Output:
1.0 2.0 3.0 0.0 0.0 6.0 8.0
The element in Row 1 Column 0 Seems to be repeated. Is this a glitch or is there a reason for it? I get similar results running the code in Emacs and I can't find info on their mailing list or searching Google for a reason. An answer to this would help others attempting to iterate over the elements of matrices and vectors.
Note: It took me a few moments to be able to run the example from the documentation at the REPL. The row separator for the reader macro is the symbol
grid:^
, so the code example is actually:The
#m
reader macro seems to create the kind of grid that would be expected.so it seems like any problem is probably coming from the implementation of the extension to Iterate. We can macroexpand the second form and see what it's being turned into, and try to figure out whether something has gone awry.
It actually looks very much like when the iteration gets to the end of a row and there are still more rows to go, rather than just incrementing the row counter and setting the column counter to zero (for the next row) and going back to the top of the loop, executes the loop body again with the element in the last column of the row. Having looked at this expansion, we can test this hypothesis by trying with some different grids:
This looks like a bug to me.
Update (2013/06/24)
I just received email from the Antik-devel list that the bug has been fixed: