APL

From Esolang
Jump to navigation Jump to search

The original APL, a notation for mathematics and programming, was invented by Ken Iverson in the late 1950s and published in his 1962 book A Programming Language. It is a non-esoteric programming language predominantly used in finance. However, due to the reliance on non-ASCII characters, unique semantics and abundance of exploratory concepts being introduced into APL even today (such as tacit function trains), it can be squarely put into the esoteric category.

The original notation for APL involved lists of statements in a box, with arrows connecting lines to indicate control flow, all written in a notation reminiscent of mathematics, complete with mixed Greek and Latin alphabets, super- and subscripts and weird invented symbols. The values of variables could be numbers, strings, multi-dimensional arrays and trees.

APL is important for two reasons: first, it turned out to be a useful notation for describing computer hardware (operational details of the IBM /360 series were all worked out in APL) and second, an interactive time-shared implementation of a big part of the language was made available around 1967. The implementation left out the tree data structures, and greatly simplified the notation to make it possible to type programs in, but retained the weird character set by using a typewriter terminal with customizable fonts (the IBM 2741, a Selectric typewriter with a computer interface.)

APL is the founding member of the APL-like family of languages, which includes J and K.

Example code

Calculate all prime numbers from 2 to 1000:

N←1000
(2=+⌿0=∘.|⍨⍳N)/⍳N

Calculate Golden mean iteratively (Dyalog APL):

1+∘÷⍣=1

Game of Life (by John Scholes):

b←1=?30 30⍴2
{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}b

External links