RANK ERROR: Difference between revisions
Miraheze>Adám Brudzewsky No edit summary |
(Fix major cell search link) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
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: | 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: | ||
< | <syntaxhighlight lang=apl> | ||
⍳2 3⍴⍳6 | ⍳2 3⍴⍳6 | ||
RANK ERROR | RANK ERROR | ||
⍳2 3⍴⍳6 | ⍳2 3⍴⍳6 | ||
∧ | ∧ | ||
</ | </syntaxhighlight> | ||
A RANK ERROR can be caused when arguments do not [[Conformability|conform]] because they have differing ranks: | A RANK ERROR can be caused when arguments do not [[Conformability|conform]] because they have differing ranks: | ||
< | <syntaxhighlight lang=apl> | ||
(2 3⍴2) + ⍳6 | (2 3⍴2) + ⍳6 | ||
RANK ERROR: Mismatched left and right argument ranks | RANK ERROR: Mismatched left and right argument ranks | ||
(2 3⍴2)+⍳6 | (2 3⍴2)+⍳6 | ||
∧ | ∧ | ||
</ | </syntaxhighlight> | ||
It may also be caused when an array's rank is too small for a function. [[Windowed Reduction]] is not defined on scalars: | It may also be caused when an array's rank is too small for a function. [[Windowed Reduction]] is not defined on scalars: | ||
< | <syntaxhighlight lang=apl> | ||
2 +/ 0.5 | 2 +/ 0.5 | ||
RANK ERROR | RANK ERROR | ||
2+/0.5 | 2+/0.5 | ||
∧ | ∧ | ||
</ | </syntaxhighlight> | ||
A RANK ERROR may be caused when argument ranks are incompatible in some other way. In languages with [[ | A RANK ERROR may be caused when argument ranks are incompatible in some other way. In languages with [[major cell search]] such as [[Dyalog APL]] and [[J]], the right argument rank of [[Index Of]] 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: | ||
< | <syntaxhighlight lang=apl> | ||
(⍳3 4) ⍳ ⊂1 3 | (⍳3 4) ⍳ ⊂1 3 | ||
RANK ERROR | RANK ERROR | ||
(⍳3 4)⍳⊂1 3 | (⍳3 4)⍳⊂1 3 | ||
∧ | ∧ | ||
</ | </syntaxhighlight> | ||
{{Works in|[[Dyalog APL]]}} | {{Works in|[[Dyalog APL]]}} | ||
{{APL features}}[[Category:Errors]] |
Latest revision as of 23:30, 10 March 2024
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 RANK ERROR ⍳2 3⍴⍳6 ∧
A RANK ERROR can be caused when arguments do not conform because they have differing ranks:
(2 3⍴2) + ⍳6 RANK ERROR: Mismatched left and right argument ranks (2 3⍴2)+⍳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 RANK ERROR 2+/0.5 ∧
A RANK ERROR may be caused when argument ranks are incompatible in some other way. In languages with major cell search such as Dyalog APL and J, the right argument rank of Index Of 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 RANK ERROR (⍳3 4)⍳⊂1 3 ∧
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 |