On 14/03/2024 10:13, Sven Schreiber wrote:
Hi,
I'm trying to find out since which gretl version it is possible to use a
foreach loop with an array of strings. The official changelog only talks
about the recent enabling of a nested array, but not of the original thing.
Example:
<hansl>
strings S = defarray("hey","ho")
loop foreach s S
print s
print "$s"
endloop
</hansl>
thanks
It looks as if the relevant git push was made on 2019-12-05:
<git>
commit 0b0d4d747692c5b5b814b0566b0655f37e71e02f
Author: Allin Cottrell <cottrell(a)wfu.edu>
Date: Thu Dec 5 13:11:02 2019 -0500
"foreach" loops: handle an array of strings
</git>
and the extension to bundles was made shortly afterwards.
Later, on 2021-01-08, this was extended to other array types:
<git>
commit 2d71f98be5582adf921c1d4a998aedc069e1da55
Author: Allin Cottrell <cottrell(a)wfu.edu>
Date: Fri Jan 8 10:45:20 2021 -0500
allow "foreach" loop for all array types
<git>
Among the lines that you find in that commit:
<code>
/* Implement "foreach" for arrays other than strings:
convert to index loop with automatic max value set
to the length of the array.
*/
</code>
So, the minimal gretl version for looping over strings array is probably
2019d, with some generalisation in 2021a. I guess we ought to update the
ChangeLog.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------