Character
- 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 | Shape ∙ Rank ∙ Depth ∙ Bound ∙ Index (Indexing) ∙ Axis ∙ Ravel ∙ Ravel order ∙ Element ∙ Scalar ∙ Vector ∙ Matrix ∙ Simple scalar ∙ Simple array ∙ Nested array ∙ Cell ∙ Major cell ∙ Subarray ∙ Empty array ∙ Prototype |
Data types | Number (Boolean, Complex number) ∙ Character (String) ∙ Box ∙ Namespace ∙ Function array |
Concepts and paradigms | Conformability (Scalar extension, Leading axis agreement) ∙ Scalar function (Pervasion) ∙ Identity element ∙ Complex floor ∙ Array ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ Glyph ∙ Leading axis theory ∙ Major cell search ∙ First-class function |
Errors | LIMIT ERROR ∙ RANK ERROR ∙ SYNTAX ERROR ∙ DOMAIN ERROR ∙ LENGTH ERROR ∙ INDEX ERROR ∙ VALUE ERROR ∙ EVOLUTION ERROR |