Difference between revisions of "RANK ERROR"

From APL Wiki
Jump to navigation Jump to search
Miraheze>Adám Brudzewsky
m (Text replacement - "{{APL programming language}}" to "{{APL features}}")
m (8 revisions imported: Migrate from miraheze)
(No difference)

Latest revision as of 14:48, 20 November 2019

A RANK ERROR is an error message which indicates that an array had an incorrect rank for the way it was used. For example, in most APLs, Iota only accepts a vector or scalar, so giving it a higher-rank array as argument results in a RANK ERROR:

      2 3⍴⍳6
      2 3⍴⍳6

A RANK ERROR can be caused when arguments do not conform because they have differing ranks:

      (2 32) + 6
RANK ERROR: Mismatched left and right argument ranks
      (2 32)+⍳6

It may also be caused when an array's rank is too small for a function. Windowed Reduction is not defined on scalars:

      2 +/ 0.5

A RANK ERROR may be caused when argument ranks are incompatible in some other way. In languages with high-rank set functions such as Dyalog APL and J, the right argument rank must be at least the left argument rank minus one. Calling it with a matrix left argument and a scalar right argument, which has a rank two smaller, gives a RANK ERROR:

      (3 4)  1 3
      (3 4)⍳⊂1 3
Works in: Dyalog APL

APL features [edit]
Built-ins Primitive functionPrimitive operatorQuad name
Array model ShapeRankDepthBoundIndexAxisRavelRavel orderElementScalarVectorMatrixSimple scalarSimple arrayNested arrayBoxCellMajor cellSubarrayEmpty arrayPrototype
Concepts and paradigms Leading axis theoryScalar extensionConformabilityScalar functionPervasionGlyphIdentity elementTotal array ordering