[iterate-devel] for i in-vector downto 0 by 2 yields what?

Hoehle, Joerg-Cyril Joerg-Cyril.Hoehle at t-systems.com
Fri Nov 12 14:19:13 UTC 2004


Hi,

I'm adding a few test cases to iterate-test.lisp. I wonder about the interaction of in-vector and by when moving backwards.

ITER> (iter (for i index-of-vector #(0 1 2 3 4) downto 0 by 2) (collect i))
(3 1)

I'd have expected (4 2 0) here. What do you think?

By analogy:
ITER> (iter(for x downfrom 4 by 2)(repeat 3)(collect x))
(4 2 0)
ITER> (loop for x downfrom 4 by 2 repeat 3 collect x)
(4 2 0)
ITER> (iter (for i index-of-vector #(0 1 2 3 4) downto 0 by 1) (collect i))
(4 3 2 1 0)
That is fine with me.

I'd expect behaviour like
(iter (for x rom (1- (length array)) downto 0 [by N]) (collect x))
(4 2 0) ; when by 2

Rationale: the first index/element it the rightmost, then walk by N.

The current behaviour looks to me like an unintended side effect of the implementation, moving down from (length array)=5 by 2 to yield 3,1.

Regards,
	Jörg Höhle.




More information about the iterate-devel mailing list