APL Wiki logo



The APL Wiki logo can be seen as the following numeric matrix, where each number indicates the circle size. This page will explain, step-by-step, an expression for this matrix — an expression which demonstrates quite a few APL features:

We will follow APL's evaluation from right to left.

From 1 or from 0?


Whether to count from 0 or from 1 is an old disagreement among programmers. Many APLs let you choose whichever convention you want, but they tend to use 1 by default. To switch convention, we set the variable : By the way, IO stands for Index Origin.

We can already now observe a couple of APL's characteristics…

No reserved words
The name  begins with the special Quad character (a stylised console) which symbolises the computer system itself. APL has no reserved words. Rather, all built-in constants, variables, functions and operators have the prefix  indicating that they are part of the system. Because of this, we call them quad names.

Assignments

 * Assignment is not done with  like in many other programming languages, but rather with   which also indicates the direction of the assignment: Whatever is on the right gets put into the name on the left.

Generating indices
The  function takes a number N and generates indices until is has made N indices. Since we set  to 0, we count from 0 until right before N:

How many subsets?
Consider a bag with four distinct items. If you stick your hand into the bag and pick two items out, how many different possibilities are there for which pair you get out? $$\{(0,1), (0,2), (0,3), (1,2), (1,3), (2,3)\}$$. APL can tell you this with the  function:

Notice how APL uses traditional mathematical symbols in a generalised way. The traditional post-fix (after its argument) symbol $$!$$ is used with a syntax similar to how you'd normally use $$+$$ or $$×$$. In fact, all APL functions can be used infix, like $$a-b$$ or prefix, like $$-b$$.

Anyway, how many sets of four could you pick? Obviously, only one; all the items: A really nice feature of APL is its array-orientation. For computations which are defined on single elements, mapping is implicit: (What's up with picking zero out of four items? Since all empty hands are equal, there is exactly one such set — the empty set.)

Order of evaluation
We want to generate the indices using … That didn't work! This is because APL dispenses with traditional mathematics' confusing and inconsistent precedence order, replacing it with a simple right-to-left rule:

Swapping arguments
If the arguments of  were swapped, we didn't need that parenthesis. Enter the operator (higher-order function) swap which takes a dyadic function on its left and creates a new derived function which is identical to the original, but has swapped arguments:

A number is a number
The next step is to halve everything: Notice how we were dealing with integers until now, but then we multiply by a float (non-integer). In APL, you don't need to worry about numeric data type conversions. All numeric types get automatically promoted and demoted as needed. APL will usually use the most compact internal representation.

Traditional mathematical symbols
Also notice that we use a proper multiplication symbol, $$×$$, for multiplication. If traditional mathematics has a symbol for a concept APL includes then APL will use that symbol. Another example is $$÷$$ for division.

Tables
Remember the multiplication table from school? Let's pause for a moment by giving our numbers a name: In fact, any function will do:

Using an argument twice
It gets tedious to type the same argument twice. Enter the selfie operator which shares its symbol with the above-mentioned swap operator. There's no ambiguity here. Swap swaps the two arguments, while selfie uses a single argument twice: We'll use this in our logo expression:

Rounding
The last step is to round these numbers down. Traditional mathematics writes floor as $$⌊x⌋$$ but APL is regular, so no function is denoted by two separated symbols. If the function takes a single argument, then the symbol will be on the left, so we write floor as : And there it is!