On Wed, 4 Dec 2019, Artur Tarassow wrote:

> Am 04.12.19 um 08:48 schrieb Sven Schreiber:
> > Am 04.12.2019 um 08:20 schrieb Artur Tarassow:
> > >
> > > Ah, that was my mistake. Sorry for the noise. I don't know why I just
> > > did not make use of the $-accessor, but tried to do some selection.
> > > The following works exactly as (I) expected it :-)
> > >
> > > <hansl>
> > > strings S = defarray("A", "B", "C")
> > > loop foreach i S -q
> > >     eval $i
> > > endloop
> >
> > ... (etc.)
> >
> > Are you sure? For me it just reproduces the object itself (array,
> > matrix...) And that's what I expected, although I totally agree with you
> > that automatically iterating would be cool.
>
> Oh ok, I've updated to latest git 1 hour ago. So maybe Allin did some work on
> this last night but hasn't finished or announced it, yet.

No, I haven't touched that code lately. Here I'm seeing what Sven
says: each of the loops prints the given object once.

A "foreach" loop works only for lists and strings. In the case of, for
example,

matrix M = seq(1,3)
loop foreach i M -q
     eval $i
endloop

the loop controller is being fed a single string, "M"; then $i dumps
that string into the "eval" line and the matrix M is printed. The loop
is therefore exactly equivalent to "eval M".

Allin

_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to