Hi,
I am not sure the following behavior of bundles and matrices data types
is intended:
While a foreach loop iterates over all items for bundles (items = keys)
and string arrays this is _not_ the case for matrices and bundle arrays
aka bundles. I think it's quite natural that it matrices and bundles
should also be "iterable" but maybe I am overlooking something.
Thanks,
Artur
<hansl>
clear
set verbose off
matrices M = array(2)
M[1] = mnormal(3,2)
M[2] = mnormal(3,2)
strings S = defarray("A", "B", "C")
bundle b = _(A = 1, B = 2)
bundles B = array(2)
B[1] = b
B[2] = b
function void foreach_matrices (const matrices X)
print "Matrices"
loop foreach i X
printf "Round %d of %d.\n", i, nelem(X)
endloop
print ""
end function
function void foreach_strings (const strings X)
print "Strings"
loop foreach i X
printf "Round %d of %d.\n", i, nelem(X)
endloop
print ""
end function
function void foreach_bundle (const bundle X)
print "bundle"
loop foreach i X
printf "Round %d of %d.\n", i, nelem(X)
endloop
print ""
end function
function void foreach_bundles (const bundles X)
print "Bundles"
loop foreach i X
printf "Round %d of %d.\n", i, nelem(X)
endloop
print ""
end function
foreach_matrices(M)
foreach_strings(S)
foreach_bundle(b)
foreach_bundles(B)
/*
Matrices
Round 1 of 2.
Strings
Round 1 of 3.
Round 2 of 3.
Round 3 of 3.
bundle
Round 1 of 2.
Round 2 of 2.
Bundles
Round 1 of 2.
*/
</hansl>