APL (programming language)

Uses your system voice; voice and rate in settings.

Snapshot

≈ 6 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

APL (named after the book A Programming Language) is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent most functions and operators, leading to very concise code. It has been an important influence on the development of concept modeling, spreadsheets, functional programming, and computer math packages. It has also inspired several other programming languages.

APL (named after the book A Programming Language) is a programming language developed in the 1960s by Kenneth E. Iverson. Its central datatype is the multidimensional array. It uses a large range of special graphic symbols to represent most functions and operators, leading to very concise code. It has been an important influence on the development of concept modeling, spreadsheets, functional programming, and computer math packages. It has also inspired several other programming languages.

Mathematical notation

A mathematical notation for manipulating arrays was developed by Kenneth E. Iverson, starting in 1957 at Harvard University. In 1960, he began work for IBM where he developed this notation with Adin Falkoff and published it in his book A Programming Language in 19621. The preface states its premise: This notation was used inside IBM for short research reports on computer systems, such as the Burroughs B5000 and its stack mechanism when stack machines versus register machines were being evaluated by IBM for upcoming computers. Iverson also used his notation in a draft of the chapter A Programming Language, written for a book he was writing with Fred Brooks, Automatic Data Processing, which would be published in 19631. In 1979, Iverson received the Turing Award for his work on APL. 'Hello, world' A design theme in APL is to define default actions in some cases that would produce syntax errors in most other programming languages. The 'Hello, world' string constant above displays, because display is the default action on any expression for which no action is specified explicitly (e.g. assignment, function parameter). x[⍋x←6?40] The above does a lot, concisely, although it may seem complex to a new APLer. It combines the following APL functions (also called primitives and glyphs ): The first to be executed (APL executes from rightmost to leftmost) is dyadic function ? (named deal when dyadic) that returns a vector consisting of a select number (left argument: 6 in this case) of random integers ranging from 1 to a specified maximum (right argument: 40 in this case), which, if said maximum ≥ vector length, is guaranteed to be non-repeating; thus, generate/create 6 random integers ranging from 1 to 40. This vector is then assigned ( ← ) to the variable x , because it is needed later. This vector is then sorted in ascending order by a monadic ⍋ function, which has as its right argument everything to the right of it up to the next unbalanced close-bracket or close-parenthesis. The result of ⍋ is the indices that will put its argument into ascending order. Then the output of ⍋ is used to index the variable x , which we saved earlier for this purpose, thereby selecting its items in ascending sequence. Since there is no function to the left of the left-most x to tell APL what to do with the result, it simply outputs it to the display (on a single line, separated by spaces) without needing any explicit instruction to do that. ? also has a monadic equivalent called roll , which simply returns one random integer between 1 and its sole operand [to the right of it], inclusive. Thus, a role-playing game program might use the expression ?20 to roll a twenty-sided die. (~R∊R∘.×R)/R←1↓⍳R Executed from right to left, this means: Iota ⍳ creates a vector containing integers from 1 to R (if R= 6 at the start of the program, ⍳R is 1 2 3 4 5 6 ) Drop first element of this vector ( ↓ function), i.e., 1 . So 1↓⍳R is 2 3 4 5 6 Set R to the new vector ( ← , assignment primitive), i.e., 2 3 4 5 6 The / replicate operator is dyadic (binary) and the interpreter first evaluates its left argument (fully in parentheses): Generate outer product of R multiplied by R , i.e., a matrix that is the multiplication table of R by R ( °.× operator), i.e., Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix ( ∈ , set inclusion or element of or Epsilon operator), i.e., 0 0 1 0 1 Logically negate (not) values in the vector (change zeros to ones and ones to zeros) ( ∼ , logical not or Tilde operator), i.e., 1 1 0 1 0 Select the items in R for which the corresponding element is 1 ( / replicate operator), i.e., 2 3 5 (This assumes the APL origin is 1, i.e., indices start with 1. APL can be set to use 0 as the origin, so that ι6 is 0 1 2 3 4 5 , which is convenient for some calculations.) X[⍋X+.≠' ';] life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵} txt←' This is emphasized text. ' {⍵ /⍨ ~{⍵∨≠\⍵}⍵∊'<>'} txt This is emphasized text.

APL2

APL2 was a significant re-implementation of APL by IBM which was developed from 1971 and first released in 19841. It provides many additions to the language, of which the most notable is nested (non-rectangular) array support. The entire APL2 Products and Services Team was awarded the Iverson Award in 2007. In 2021, IBM sold APL2 to Log-On Software, who develop and sell the product as Log-On APL2. An APL Machine (1970 Stanford doctoral dissertation by Philip Abrams) A Personal History Of APL (1982 article by Michael S. Montalbano) A Programming Language by Kenneth E. Iverson APL in Exposition by Kenneth E. Iverson Brooks, Frederick P.; Kenneth Iverson (1965). Automatic Data Processing, System/360 Edition. .

Text derived from https://en.wikipedia.org/w/index.php?oldid=1374410077 under CC BY-SA 4.0; modifications have been made.

References

  1. ↩Wikipedia “APL (programming language)” revision 1374410077 · retrieved 2026-10-20 publication date (×3) · confidence 0.95 revision URL