Shape: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Miraheze>RikedyP
(Created page with "The shape of an array is a vector of lengths of the dimensions of the array. The shape funcion <code class="apl">⍴</code> returns the shape of its right argument array. <pre...")
 
Miraheze>Adám Brudzewsky
No edit summary
Line 1: Line 1:
The shape of an array is a vector of lengths of the dimensions of the array. The shape funcion <code class="apl">⍴</code> returns the shape of its right argument array.
The shape of an array is a vector of lengths of the dimensions of the array. The shape function <code class="apl">⍴</code> returns the shape of its right argument array.
<pre class="apl">
<pre class="apl">
       (⍬≡⍴)¨1 'A'                ⍝ The shape of a scalar is the empty numeric vector ⍬
       (⍬≡⍴)¨1 'A'                ⍝ The shape of a scalar is the empty numeric vector ⍬
Line 10: Line 10:
3 4 2
3 4 2
</pre>
</pre>
{{APL programming language}}

Revision as of 20:38, 26 September 2019

The shape of an array is a vector of lengths of the dimensions of the array. The shape function returns the shape of its right argument array.

      (⍬≡⍴)¨1 'A'                 ⍝ The shape of a scalar is the empty numeric vector ⍬
1 1
      ⍴'ABCDE'                    ⍝ The shape of a vector is a length-1 vector
5
      ⍴'ABC'∘.,1 2 3 4            ⍝ The shape of the matrix result of an outer product
3 4
      ⍴'ABC'∘.,1 2 3 4∘.×0J1 1J2  ⍝ Two consecutive outer products result in a cuboid
3 4 2

Template:APL programming language