Character arithmetic

From APL Wiki
Jump to navigation Jump to search

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 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 floorArray ordering (Total) ∙ Tacit programming (Function composition, Close composition) ∙ GlyphLeading axis theoryMajor cell searchFirst-class function
Errors LIMIT ERRORRANK ERRORSYNTAX ERRORDOMAIN ERRORLENGTH ERRORINDEX ERRORVALUE ERROREVOLUTION ERROR