Countdown max...min IntIter

Ever needed to use a reverse IntIter to go through an array ? E.g. to update a recently used list of items ?

This does not work:

currIndex = 5;

for (i in currIndex...0) recentlyUsed[i] = recentlyUsed[i - 1];
recentlyUsed[0] = "New Item...";

because IntIter forbids the second argument being less or equal than the first.

But it will accept it when you multiply both IntIter arguments with -1:

currIndex = 5;

for (i in -currIndex...0) recentlyUsed[-i] = recentlyUsed[-i - 1];
recentlyUsed[0] = "New Item...";

Just don't forget to multiply your iterator value with -1 when used...

version #6910, modified 2009-08-31 01:02:18 by mloots