Arithmetic operation on a variable or reference
name += expression
name -= expression
name *= expression
name /= expression
reference += expression
reference -= expression
reference *= expression
reference /= expression
Operators perform an arithmetic operation with arguments:
- on the left: a variable with the name or a value of the reference (element of
an array or list)
- on the right: value of the expression.
The result is written into the variable or reference used on the left side of the operator.
Example:
to vsum :a
let "sum 0
if array? :a || list? :a [
foreach "x :a ["sum += :x]
]
output :sum
end
to vscale :a :x
if (array? :a || list? :a) && number? :x [
repeat count :a [:a,repcount *= :x]
]
end
"v := {1 2 3 4 5}
print vsum :v
vscale :v 2
print :v
Output:
15
{2 4 6 8 10}
See also:
Variables in POOL
:= - assign new value to a variable/reference
make, name - set or create global variable
let, localmake - set or create local variable
Table of Content