APLX Help : Help on APL language : APL Fundamentals : Branching and labels
|
|
![]() |
Branching and labels |
Traditionally, the APL right arrow ' The symbol A label is a name which is followed by a colon. It is placed at the start of the line which it identifies it. When the function is running, it is treated as a local variable whose value is the number of the line on which it is placed. It can thus be used directly as the argument of the right arrow. A special case arises if no argument is given to the right arrow (a 'naked branch'). This terminates execution of the current function and of all functions which called it, removes them from the state indicator, and returns to desk-calculator mode. If the APL interpreter is already in desk-calculator mode, this will have the effect of removing the top function and all thouse down to the next function marked with an asterisk in the Examples:To branch back from line 10 to line 3: [10] →3 To branch unconditionally to a line labelled [10] →LAB2 [11] ... [12] LAB2:TOTAL←QTY×PRICE To branch to a line labelled [10] →(LOOP=10)/LAB2 [11] ... [12] LAB2:TOTAL←QTY×PRICE To branch to one of several lines depending on the value of the variable [6] →(CASE1 CASE2 CASE3)[INDEX] To branch to one of several lines using a boolean vector to select which (execution will continue at the label corresponding to the first 1 in the vector. If there is none, a message will be displayed and the function will end): [6] →SELECT/(CASE1 CASE2 CASE3) ⋄ 'No case applies' ⋄ →0 |
|
APLX Help : Help on APL language : APL Fundamentals : Branching and labels
|
Copyright © 1996-2010 MicroAPL Ltd