Clearly, you can follow Jack's suggestion.
In my suggestion, i.e.:
loop foreach i 48 60 100 250 400 780
...
endloop
i is taken as a string.
But you can always recall it inside the loop using $i:
- defining a new scalar. E.g:
loop foreach i 48 60 100 250 400 780
scalar j = $i
...
endloop
- or use it directly in the loop.
So, for instance, the following code works as expected:
series A = 0
loop foreach i 48 60 100 250 400 780
A[$i] = $i
endloop
Bye
Giuseppe
On Wed, 2011-11-30 at 11:53 +0100, Riccardo (Jack) Lucchetti wrote:
On Wed, 30 Nov 2011, Ignacio Diaz-Emparanza wrote:
> I need to build a loop with a not regulary spaced index, ¿what do you
> think it is the best way?
>
> I mean, for example a loop over i=48, 60, 100, 250, 400, 780
Something like this, perhaps?
<hansl>
x = {48, 60, 100, 250, 400, 780}
loop i=1..cols(x) --quiet
j = x[i]
printf "%d -> %d\n",i, j
end loop
</hansl>
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti
_______________________________________________ Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users