138
Labels are local to a function-which means they can only be used within that
function. Following are some additional rules that apply to the use of labels:
0 They must not appear in the function header.
You cannot assign values to them.
0 They can be up to 77 characters in length.
They cannot be used on comments.
0 When duplicate labels or labels that duplicate a local name are used, the first
use of the label or name is the accepted use.
If the branch is to zero (-to) or any statement number not in the function, the
function is exited when the branch statement is executed. If the value to the right
of the + is a vector (for example, +LI,L2,L3), the branch is determined by the
vector's first element. If the vector is an empty vector (there are no elements), the
branch is not executed, and the normal sequence of statement execution continues.
For example, the conditional branch +(I ?N)/START is evaluated as follows:
1. First, the condition (I?N) is evaluated; the result is 1 if the condition is
true and 0 if the condition is false.
2. The result of step 1 is then used as the left argument for the compress
(A/B) function:
a. If the result of step 1 was 1, START is selected from the right argument
and a branch to the statement labeled START is taken.
b. If the result of step 1 was 0, nothing is selected from the right argument
(an empty vector is the result) and the sequence of execution falls through
to the next statement.
Following are three examples of defining and using a function to determine the
sum of the first N
integers. Each function uses a different method of branching.
Remember, the expression to the right of the + is evaluated and the result deter.
mines to what statement the branch is taken:
SlJM :I. 5
1.5
Labels are local to a function-which means they can only be used within that
function. Following are some additional rules that apply to the use of labels:
0 They must not appear in the function header.
You cannot assign values to them.
0 They can be up to 77 characters in length.
They cannot be used on comments.
0 When duplicate labels or labels that duplicate a local name are used, the first
use of the label or name is the accepted use.
If the branch is to zero (-to) or any statement number not in the function, the
function is exited when the branch statement is executed. If the value to the right
of the + is a vector (for example, +LI,L2,L3), the branch is determined by the
vector's first element. If the vector is an empty vector (there are no elements), the
branch is not executed, and the normal sequence of statement execution continues.
For example, the conditional branch +(I ?N)/START is evaluated as follows:
1. First, the condition (I?N) is evaluated; the result is 1 if the condition is
true and 0 if the condition is false.
2. The result of step 1 is then used as the left argument for the compress
(A/B) function:
a. If the result of step 1 was 1, START is selected from the right argument
and a branch to the statement labeled START is taken.
b. If the result of step 1 was 0, nothing is selected from the right argument
(an empty vector is the result) and the sequence of execution falls through
to the next statement.
Following are three examples of defining and using a function to determine the
sum of the first N
integers. Each function uses a different method of branching.
Remember, the expression to the right of the + is evaluated and the result deter.
mines to what statement the branch is taken:
SlJM :I. 5
1.5