4,493
edits
m (Text replacement - "<source" to "<syntaxhighlight") Tags: Mobile edit Mobile web edit |
|||
(4 intermediate revisions by the same user not shown) | |||
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]] < | {{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 == | ||
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: | ||
< | <syntaxhighlight lang=apl> | ||
{⍵(⍴⍵)}⍪5⍴⎕A | {⍵(⍴⍵)}⍪5⍴⎕A | ||
┌─┬───┐ | ┌─┬───┐ | ||
Line 25: | Line 25: | ||
│MNOPQRSTUVWX│ │ | │MNOPQRSTUVWX│ │ | ||
└────────────┴────┘ | └────────────┴────┘ | ||
</ | </syntaxhighlight> | ||
A [[scalar]] [[argument]] is converted to a 1-by-1 matrix: | A [[scalar]] [[argument]] is converted to a 1-by-1 matrix: | ||
< | <syntaxhighlight lang=apl> | ||
{⍵(⍴⍵)}⍪123 | {⍵(⍴⍵)}⍪123 | ||
┌───┬───┐ | ┌───┬───┐ | ||
│123│1 1│ | │123│1 1│ | ||
└───┴───┘ | └───┴───┘ | ||
</ | </syntaxhighlight> | ||
== Properties == | == Properties == | ||
Line 40: | Line 40: | ||
Table preserves the array's [[Tally]] (the number of major cells). | Table preserves the array's [[Tally]] (the number of major cells). | ||
Table is equivalent to [[reshape|reshaping]] with the shape where all trailing axis lengths have been replaced by their [[product], | 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: | ||
< | <syntaxhighlight lang=apl> | ||
⍪2 3 4 2⍴⎕A | ⍪2 3 4 2⍴⎕A | ||
ABCDEFGHIJKLMNOPQRSTUVWX | ABCDEFGHIJKLMNOPQRSTUVWX | ||
Line 51: | Line 51: | ||
ABCDEFGHIJKLMNOPQRSTUVWX | ABCDEFGHIJKLMNOPQRSTUVWX | ||
YZABCDEFGHIJKLMNOPQRSTUV | YZABCDEFGHIJKLMNOPQRSTUV | ||
</ | </syntaxhighlight> | ||
In languages where the [[Rank (operator)|Rank operator]] is available, Table is equivalent to <syntaxhighlight lang=apl inline>,⍤¯1</syntaxhighlight>: | |||
<syntaxhighlight lang=apl> | |||
(,⍤¯1)2 3 4 2⍴⎕A | |||
ABCDEFGHIJKLMNOPQRSTUVWX | |||
YZABCDEFGHIJKLMNOPQRSTUV | |||
</syntaxhighlight> | |||
In languages where [[function axis]] is available, Table is equivalent to <syntaxhighlight lang=apl inline>,[1↓⍳≢⍴Y]</syntaxhighlight>: | |||
<syntaxhighlight lang=apl> | |||
{,[1↓⍳≢⍴⍵]⍵}2 3 4 2⍴⎕A | |||
ABCDEFGHIJKLMNOPQRSTUVWX | |||
YZABCDEFGHIJKLMNOPQRSTUV | |||
</syntaxhighlight> | |||
== External links == | == External links == | ||
Line 61: | Line 74: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/latest/#Language/Primitive%20Functions/Enlist.htm Dyalog] | ||
* J [https://www.jsoftware.com/help/dictionary/d321.htm Vocabulary], [https://code.jsoftware.com/wiki/Vocabulary/commadot NuVoc] | * J [https://www.jsoftware.com/help/dictionary/d321.htm Vocabulary], [https://code.jsoftware.com/wiki/Vocabulary/commadot NuVoc] | ||
{{APL built-ins}}[[Category:Primitive functions]] | {{APL built-ins}}[[Category:Primitive functions]] |