Maybe i´m asking too much, but...
I need to loop through a very large table and execute something just for certain elements.
For example, instead of writing:
do i = 1 until i > 100000
if not i in 1, 570, 800, 900, 1050, 48560, 94980 then //a list of indexes
next; //skip the ones I do not want to process
endif;
//do something for the ones I want to process
mat(i) = 3; //for example
enddo;
I would write:
do i in 1, 570, 800, 900, 1050, 48560, 94980
//do something for the ones I want to process
mat(i) = 3; //for example
enddo;
Besides being much faster because it would not look through the whole table filtering the ones to process, it would be much "cleaner" also.
Best
Ari
Do i in x,y,z
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Do i in x,y,z
You could put those values in an array. Something like:
PROC GLOBAL
numeric NumberValues = 7;
array Values(NumberValues) = 1, 570, 800, 900, 1050, 48560, 94980;
// ...
do numeric ctr = 1 while ctr <= NumberValues
// do something with Values(ctr)
enddo;
numeric NumberValues = 7;
array Values(NumberValues) = 1, 570, 800, 900, 1050, 48560, 94980;
// ...
do numeric ctr = 1 while ctr <= NumberValues
// do something with Values(ctr)
enddo;