Do i in x,y,z
Posted: July 10th, 2018, 7:59 pm
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
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