up previous next
incr, decr

increment/decrement a counter

Syntax
incr(ref X: INT)
decr(ref X: INT)

Description
incr(ref X) adds 1 to the value of X . decr(ref X) subtracts 1 from the value of X .

These functions are useful when counting objects or adjusting pointers.

Example
/**/ L := [(10^k-1)/9 | k in 1..99];
/**/ NPrimes := 0;
/**/ Foreach N in L Do
/**/   If IsPrime(N) Then incr(ref NPrimes); EndIf;
/**/ EndForeach;
/**/ PrintLn "The list L contains ", NPrimes, " primes.";
The list L contains 3 primes.