Table: Difference between revisions

Jump to navigation Jump to search
History
(Created page with "{{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 giv...")
 
(History)
 
(7 intermediate revisions by one other 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]] <source lang=apl inline>⍪</source> with the dyadic function [[catenate|Catenate First]].
:''This page is about the function that reshapes into a table. For the operator that generates a table of all combinations, see [[Outer Product]].''
{{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. In languages where [[Rank (operator)|Rank operator]] is available, Table is equivalent to <source lang=apl inline>,⍤¯1</source>.
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 25: Line 26:
│MNOPQRSTUVWX│    │
│MNOPQRSTUVWX│    │
└────────────┴────┘
└────────────┴────┘
</source>
</syntaxhighlight>


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
┌───┬───┐
┌───┬───┐
│123│1 1│
│123│1 1│
└───┴───┘
└───┴───┘
</source>
</syntaxhighlight>


== Properties ==
== Properties ==


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]] or, alternatively, the tally concatenated to the [[bound]] divided by the tally:
<syntaxhighlight lang=apl>
      ⍪2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
YZABCDEFGHIJKLMNOPQRSTUV
      {⍵⍴⍨(≢⍵),(×/⍴⍵)÷≢⍵}2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
YZABCDEFGHIJKLMNOPQRSTUV
      {⍵⍴⍨(1↑⍴⍵),(×/1↓⍴⍵)}2 3 4 2⍴⎕A
ABCDEFGHIJKLMNOPQRSTUVWX
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>
== History ==
Table was implemented in [[SHARP APL]] release 19.0,<ref>[[Robert Bernecky]]. [https://dl.acm.org/citation.cfm?id=55632 An Introduction to Function Rank] at [[APL88]]. [[APL Quote Quad]], Volume 18, Issue 2. December 1987.</ref> and included in [[A Dictionary of APL]] in the same year. It was eventually included [[ISO/IEC 13751:2001]] standard, although other dialects had generally not adopted it: a 2005 review lists only a non-conforming implementation in [[APLX]].<ref>F.H.D. van Batenburg. [http://archive.vector.org.uk/art10000930 Conformity of APL Implementations to the ISO APL Standard]. [[Vector journal]] Volume 21, No.3. 2005-05.</ref> Table was added in [[Dyalog APL 12.1]], released in 2009, and it generally appears in modern dialects (for example [[ngn/apl]] and [[Kap]]).


== External links ==
== External links ==
Line 48: Line 79:
=== Documentation ===
=== Documentation ===


* [http://help.dyalog.com/latest/#Language/Primitive%20Functions/Enlist.htm Dyalog]
* [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]]

Navigation menu