The following keywords are used for controlling the execution flow in the APL programming language.
Keyword | Description | Example | |||||
---|---|---|---|---|---|---|---|
break | Terminates the execution of the current loop. | while(i++ < 10) { if( i == 5 ) { break; } } | |||||
continue | Terminates execution of the current iteration of the loop, and continues execution of the next iteration. | while( i++ < 10) { if( i%2 == 0 //your code { else { continue; } } } | |||||
for |
The
Creates a loop that consists of three expressions. The first expression performs the initialization of a variable used for counting iterations. A variable declared in this expression is only available in the scope of the for loop. The second expression contains a condition that must be evaluated evaluate to true or false. The loop iterates until the condition evaluates to false. The third expression is evaluated at the end of each loop iteration, before the next evaluation of the condition. This is typically used to update or increment the counting variable in the condition. | list<int> listOfInts = listCreate(int,1,2,3); for (int i: listOfInts) { //your code } list<string> listOfStrings = listCreate(string,"1","2","3"); for (string s: listOfStrings) { //your code } for( int i=0; i<10; i++ ) { } | |||||
if else | Used to execute code with conditions. | if (myVar == "ABC") {// do_this} else {// do_that} | |||||
return | Stops the execution of the current function block. | if ( ANumber == null ) { return;} | |||||
while | Loops while a condition is true.
| while( i < 20 ) { // do_stuff} | |||||
switch case | Allows an expression to be tested for equality against a list of values or types, where each of these is a case. The cases are evaluated against the variable in order, from top to bottom. After a match, the remaining cases will not be evaluated. Testing values: The value for a Testing types: The type for a A switch statement can have an optional default case, | //Testing values switch (str) { case "one" { debug("One"); } case "two" { debug("Two"); } else debug("other"); } //Testing types switch (input) { case (PulseUDR p){ debug(p.Sequence); } case (MyUDR m) { debug(m.aField); } } //Testing container types switch (value) { |
...