Scriptol/Scan By
Appearance
< Scriptol
Scan By
[edit | edit source]Common syntax
[edit | edit source]The scan control structure allows to parse one or several arrays, and to apply a process onto each element of the array(s).
scan a
a[] * a[] print a[]
/scan
The current element is denoted by an empty indice.
Example with two arrays:
scan a, b print a[] + b[] /scan
Scan with a function
[edit | edit source]You can apply instead a predefined function. The argument of the function is an element of the array.
array a = {1,2,3,4 }
void fun(number x) print x * x return
scan a by fun
If you use several arrays, the number of argument of the function must be the number of array.