From APL Wiki
Jump to navigation Jump to search
This page is about the data type. For the symbols used to write APL code, see Glyph.

A character is a scalar array representing a unit of text. In current APLs this generally means a Unicode code point, while historically various custom character sets were used. These accomodated typical text as well as APL code, usually with one byte per character. Characters and numbers are the two basic data types in APL. Strings are represented as vectors of characters, although a separate string datatype is sometimes proposed, and implemented in APL64.

A character literal is written with the same syntax as a string, such as 'c'. This syntax produces a scalar character (rather than a vector) when there's only one character between the quotes.

In most dialects, characters can be compared for equality, and are subject to array ordering as in Grade, but can't be compared with inequalities such as less than ('a'<'b' gives a DOMAIN ERROR). Character arithmetic extends addition and subtraction to characters, and is supported in the Kap dialect, as well as BQN and Uiua. These languages also allow inequality comparisons on characters.

In other array languages, particularly K, the character type may indicate a non-textual unit, such as bytes with a UTF-8 representation for unicode text. This differs from a 1-byte character encoding in that a single byte may not have any meaning on its own, being instead a possible component of many unrelated characters.

APL features [edit]
Built-ins Primitives (functions, operators) ∙ Quad name
Array model ShapeRankDepthBoundIndex (Indexing) ∙ AxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayCellMajor cellSubarrayEmpty arrayPrototype
Data types Number (Boolean, Complex number) ∙ Character (String) ∙ BoxNamespaceFunction array
Concepts and paradigms Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity elementComplex floorTotal array orderingTacit programming (Function composition, Close composition) ∙ Glyph