Table: Difference between revisions

Jump to navigation Jump to search
72 bytes added ,  10:59, 11 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - "</source>" to "</syntaxhighlight>")
Tags: Mobile edit Mobile web edit
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
Line 1: Line 1:
{{Built-in|Table|⍪}}, or '''Ravel Items''', is a [[monadic]] [[primitive function]] which returns a [[matrix]] formed by applying [[Ravel]] to each [[major cell]] of the given array. Table shares its [[glyph]] <source lang=apl inline>⍪</syntaxhighlight> with the dyadic function [[catenate|Catenate First]].
{{Built-in|Table|⍪}}, or '''Ravel Items''', is a [[monadic]] [[primitive function]] which returns a [[matrix]] formed by applying [[Ravel]] to each [[major cell]] of the given array. Table shares its [[glyph]] <syntaxhighlight lang=apl inline>⍪</syntaxhighlight> with the dyadic function [[catenate|Catenate First]].


== Examples ==
== Examples ==
Line 5: Line 5:
For arrays of [[rank]] 1 or higher, the result is identical to applying Ravel to major cells:
For arrays of [[rank]] 1 or higher, the result is identical to applying Ravel to major cells:


<source lang=apl>
<syntaxhighlight lang=apl>
       {⍵(⍴⍵)}⍪5⍴⎕A
       {⍵(⍴⍵)}⍪5⍴⎕A
┌─┬───┐
┌─┬───┐
Line 29: Line 29:
A [[scalar]] [[argument]] is converted to a 1-by-1 matrix:
A [[scalar]] [[argument]] is converted to a 1-by-1 matrix:


<source lang=apl>
<syntaxhighlight lang=apl>
       {⍵(⍴⍵)}⍪123
       {⍵(⍴⍵)}⍪123
┌───┬───┐
┌───┬───┐
Line 41: Line 41:


Table is equivalent to [[reshape|reshaping]] with the shape where all trailing axis lengths have been replaced by their [[product]] or, alternatively, the tally concatenated to the [[bound]] divided by the tally:
Table is equivalent to [[reshape|reshaping]] with the shape where all trailing axis lengths have been replaced by their [[product]] or, alternatively, the tally concatenated to the [[bound]] divided by the tally:
<source lang=apl>
<syntaxhighlight lang=apl>
       ⍪2 3 4 2⍴⎕A
       ⍪2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWX
Line 53: Line 53:
</syntaxhighlight>
</syntaxhighlight>


In languages where the [[Rank (operator)|Rank operator]] is available, Table is equivalent to <source lang=apl inline>,⍤¯1</syntaxhighlight>:
In languages where the [[Rank (operator)|Rank operator]] is available, Table is equivalent to <syntaxhighlight lang=apl inline>,⍤¯1</syntaxhighlight>:
<source lang=apl>
<syntaxhighlight lang=apl>
       (,⍤¯1)2 3 4 2⍴⎕A
       (,⍤¯1)2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWX
YZABCDEFGHIJKLMNOPQRSTUV
YZABCDEFGHIJKLMNOPQRSTUV
</syntaxhighlight>
</syntaxhighlight>
In languages where [[function axis]] is available, Table is equivalent to <source lang=apl inline>,[1↓⍳≢⍴Y]</syntaxhighlight>:
In languages where [[function axis]] is available, Table is equivalent to <syntaxhighlight lang=apl inline>,[1↓⍳≢⍴Y]</syntaxhighlight>:
<source lang=apl>
<syntaxhighlight lang=apl>
       {,[1↓⍳≢⍴⍵]⍵}2 3 4 2⍴⎕A
       {,[1↓⍳≢⍴⍵]⍵}2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWX

Navigation menu