Scalar extension: Difference between revisions

Jump to navigation Jump to search
32 bytes added ,  14:54, 9 September 2022
Make clearer what's going on
(Make clearer what's going on)
Line 16: Line 16:
=== Rank extension ===
=== Rank extension ===


The term "scalar extension" is sometimes used to refer to the practice of allowing a scalar when a higher rank is expected. The scalar is treated as an array of the expected minimum rank whose shape is a vector of 1s (that is, a [[singleton]]). For example, <source lang=apl inline>⍳8</source> and <source lang=apl inline>8⍴'a'</source> both produce an 8-element array even though the shape of an array is always a vector and so cannot be equal to <source lang=apl inline>8</source>. This type of extension, which differs from ordinary scalar extension in that there is no expected shape and only an expected rank, has also been present since [[APL\360]].
The term "scalar extension" is sometimes used to refer to the practice of allowing a scalar when a higher rank is expected. The scalar is treated as an array of the expected minimum rank whose shape is a vector of 1s (that is, a [[singleton]]). For example, <source lang=apl inline>⍳8</source> and <source lang=apl inline>8⍴'a'</source> both produce an array of shape <source lang=apl inline>,8</source> (a vector) even though they were given a shape specification of <source lang=apl inline>8</source> (a scalar). This type of extension, which differs from ordinary scalar extension in that there is no expected shape and only an expected rank, has also been present since [[APL\360]].


=== Singleton extension ===
=== Singleton extension ===

Navigation menu