|  3DSoftware.com > Programming > APL |
| Introduction to APL |
|
APL was a computer programming language in the 1970s.
It is still available on some systems. This is an
introduction to APL for programmers who have APL
available on their system. In our examples, the APL prompt will look like this:
On your system, the APL prompt may be |
|
APL starts up in calculator mode (immediate mode). You type a line of Then APL displays the result. For example, to multiply
The result is displayed on the next line. Then the APL prompt appears on the line after that, and waits for you to enter another line of code. Assignment is easy in APL, with the
As shown, when you enter the name of a variable by itself at the After displaying the contents of the variable in that example, the |
|
|
|
In the last example above, a variable
To display a list of variables that have already been defined in your workspace, enter |
To undefine a variable you will no longer be using,
use the
After you use the |
|
|
| Creating vectors in APL is easy. Simply assign a list of numbers to a variable. You can then perform operations on that variable, such as scalar multiplication (as shown in the example at right). |
|
|
|
| You can also use a vector on the fly, without assigning it to a variable. And vector components can themselves be expressions. |
|
|
|
|
APL includes a wealth of
functions
and
adverbs
for handling vectors.
An example is |
|
|
|
You can also rotate (barrel shift) a vector.
That is done with the rotate symbol,
which is a combination of the vertical
bar and circle, as shown below:
|
|
| An important feature of APL is the ability to create such symbols by simply typing one symbol over another (in this case combining the vertical bar symbol with the circle symbol). | The number before the rotate symbol specifies how many cells to rotate (toward the left if that number is positive, or toward the right if it is negative). |
|
|
|
The rotate symbol is only a rotate symbol if
it has a number before it. If it does not have a number before it, then it is the reversal symbol. |
|
|
|
|
|
|
| References |
|
Raymond P. Polivka and Sandra Pakin APL: The Language and Its Usage |
|
Copyright © 2008 by 3D Software. All rights reserved. 3D Software, P.O. Box 221190, Sacramento CA 95822 USA www.3DSoftware.com Contact us |
| Thursday, 28-Aug-2008 04:11:00 GMT |