Box

From APL Wiki
Jump to navigation Jump to search

In the flat array model, a box is a scalar value which "contains" a single arbitrary array. This array can be obtained by unboxing the box, and any array can be enclosed in a box using the Box, or Enclose, function. A box corresponds to the nested array theory concept of an enclosed array, and an array of boxes (a "boxed array") to a nested array.

Boxes are one of three possible types for array elements in most flat array languages, the other two being character and numeric data. Because they can store any array, boxes may be used to define arrays which contain both numbers and characters, as well as arrays with a nested structure.

The Equals and Not Equals functions compare boxes (as scalar functions, they apply only to individual boxes) by comparing whether the contained arrays match. Other scalar functions usually give a DOMAIN ERROR when passed boxed arguments; this differs from the nested array convention of recursing into nested arrays. Because of this behavior scalar functions in nested APLs are said to be pervasive while those in flat APLs are not.

Simple scalars in nested array languages float, so that an enclosed simple scalar is equal to that simple scalar. In flat APLs this does not happen: boxing an array always results in a different array which has one greater depth.


APL features [edit]
Syntax ArrayFunctionOperatorAssignment
Built-ins Primitive functionPrimitive operatorQuad name
Array model ShapeRankDepthBoundIndexAxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayBoxCellMajor cellSubarrayEmpty arrayPrototype
User definition TradfnDfnTacit
Concepts and paradigms Leading axis theoryScalar extensionConformabilityScalar functionGlyphIdentity element
Errors LIMIT ERRORRANK ERROR