Character arithmetic
Affine character arithmetic is a system that defines addition and subtraction in certain cases involving character arguments. In this system, a number can be added to or subtracted from a character to give another character, and two characters can be subtracted to give a number. These are the same operations allowed in an affine space, and on types such as pointers. Character arithmetic was developed in BQN and subsequently included in Kap, Uiua, and TinyAPL. It independently appears in Julia, where it applies to characters only and not strings.
In K, characters are converted to numbers to participate in arithmetic. This system differs from affine character arithmetic in that it allows more operations, for example adding two characters together, and always returns a number, rather than determining the result type based on the input types.
Documentation
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 |