Difference between revisions of "RANK ERROR"

From APL Wiki
Jump to navigation Jump to search
Miraheze>Marshall
m
Miraheze>Adám Brudzewsky
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 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 results in a RANK ERROR:
<pre class=apl>
+
<source=apl>
 
       ⍳2 3⍴⍳6
 
       ⍳2 3⍴⍳6
 
RANK ERROR
 
RANK ERROR
 
       ⍳2 3⍴⍳6
 
       ⍳2 3⍴⍳6
 
       ∧
 
       ∧
</pre>
+
</source>
  
 
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:
<pre class=apl>
+
<source=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
 
             ∧
 
             ∧
</pre>
+
</source>
  
 
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:
<pre class=apl>
+
<source=apl>
 
       2 +/ 0.5
 
       2 +/ 0.5
 
RANK ERROR
 
RANK ERROR
 
       2+/0.5
 
       2+/0.5
 
       ∧
 
       ∧
</pre>
+
</source>
  
 
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:
 
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:
<pre class=apl>
+
<source=apl>
 
       (⍳3 4) ⍳ ⊂1 3
 
       (⍳3 4) ⍳ ⊂1 3
 
RANK ERROR
 
RANK ERROR
 
       (⍳3 4)⍳⊂1 3
 
       (⍳3 4)⍳⊂1 3
 
             ∧
 
             ∧
</pre>
+
</source>
 
{{Works in|[[Dyalog APL]]}}
 
{{Works in|[[Dyalog APL]]}}

Revision as of 15:05, 17 October 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 results in a RANK ERROR: <source=apl>

     ⍳2 3⍴⍳6

RANK ERROR

     ⍳2 3⍴⍳6
     ∧

</source>

A RANK ERROR can be caused when arguments do not conform because they have differing ranks: <source=apl>

     (2 3⍴2) + ⍳6

RANK ERROR: Mismatched left and right argument ranks

     (2 3⍴2)+⍳6
            ∧

</source>

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

     2 +/ 0.5

RANK ERROR

     2+/0.5
      ∧

</source>

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: <source=apl>

     (⍳3 4) ⍳ ⊂1 3

RANK ERROR

     (⍳3 4)⍳⊂1 3
           ∧

</source>

Works in: Dyalog APL