The vector-valued variables in the math parser have a fixed size, determined at the compile-time when the variable is defined.
To manage vectors with a dynamic size, there is anyway the solution to define an image (e.g a 1x1 image), and use the functions dar_insert(), dar_size()
and dar_remove()
from the math_lib
,just like this (dar
stands for dynamic array
).
foo:
1 # Insert a 1x1 image at slot #0 (cannot be empty).
eval ${-math_lib}" # Include functions from the math_lib
for (k = 0, k<10, ++k,
dar_insert(#0,k); # Insert element 'k' at the end of the dynamic array
);
for (k = 0, k<5, ++k,
dar_remove(#0,k+3); # Remove elements.
);
# Display array content.
for (k = 0, k<dar_size(#0), ++k,
print(I[#0,k]);
);
The image contains both the values of the dynamic array and the number of elements (stored as the last value of the image).