a ← expression
.
a ← 1
b ← a
a ← 2
DISPLAY(b) // Displays 1
[value1, value2, value3, ...]
).aList ← [value1, value2, value3, ...]
or aList ← []
for an empty list.a MOD b
evaluates to the remainder when a
is divided by b
(e.g., 17 MOD 5 = 2).+
, -
, *
, /
, MOD
(e.g., 17 / 5 = 3.4).MOD
has the same precedence as *
and /
.=
, ≠
, >
, <
, ≥
, ≤
.NOT
, AND
, OR
.NOT condition
evaluates to true if condition is false, otherwise false.condition1 AND condition2
evaluates to true if both conditions are true, otherwise false.condition1 OR condition2
evaluates to true if either condition is true, or both, otherwise false.IF(condition) { <block of statements> }
executes the block if condition is true.IF(condition) { <first block of statements> } ELSE { <second block of statements> }
executes the first block if condition is true, otherwise the second block.REPEAT n TIMES { <block of statements> }
executes the block n
times.REPEAT UNTIL(condition) { <block of statements> }
repeats the block until the condition is true.REPEAT UNTIL
, an infinite loop occurs if the ending condition never evaluates to true.REPEAT UNTIL
, if the conditional is initially true, the loop body is not executed.aList[i]
), assigning values to variables (x ← aList[i]
), and assigning values to elements (aList[i] ← x
).aList[i] ← aList[j]
INSERT(aList, i, value)
APPEND(aList, value)
REMOVE(aList, i)
LENGTH(aList)
FOR EACH item IN aList { <block of statements> }
assigns each element of aList
to item
sequentially.procName(arg1, arg2, ...)
.DISPLAY(expression)
displays the value of the expression, followed by a space.RETURN(expression)
returns control and the expression's value to the calling point.result ← procName(arg1, arg2, ...)
assigns the returned value to result
.INPUT()
accepts a value from the user and returns it.
PROCEDURE procName(parameter1, parameter2, ...) {
<block of statements>
}
PROCEDURE procName(parameter1, parameter2, ...) {
<block of statements>
RETURN(expression)
}
RANDOM(a, b)
generates a random integer from a
to b
, inclusive.