Table
- This page is about the function that reshapes into a table. For the operator that generates a table of all combinations, see Outer Product.
⍪
|
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 ⍪
with the dyadic function Catenate First.
Examples
For arrays of rank 1 or higher, the result is identical to applying Ravel to major cells:
{⍵(⍴⍵)}⍪5⍴⎕A ┌─┬───┐ │A│5 1│ │B│ │ │C│ │ │D│ │ │E│ │ └─┴───┘ {⍵(⍴⍵)}⍪3 4⍴⎕A ┌────┬───┐ │ABCD│3 4│ │EFGH│ │ │IJKL│ │ └────┴───┘ {⍵(⍴⍵)}⍪2 3 4⍴⎕A ┌────────────┬────┐ │ABCDEFGHIJKL│2 12│ │MNOPQRSTUVWX│ │ └────────────┴────┘
A scalar argument is converted to a 1-by-1 matrix:
{⍵(⍴⍵)}⍪123 ┌───┬───┐ │123│1 1│ └───┴───┘
Properties
Table preserves the array's Tally (the number of major cells).
Table is equivalent to 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:
⍪2 3 4 2⍴⎕A ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV {⍵⍴⍨(≢⍵),(×/⍴⍵)÷≢⍵}2 3 4 2⍴⎕A ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV {⍵⍴⍨(1↑⍴⍵),(×/1↓⍴⍵)}2 3 4 2⍴⎕A ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV
In languages where the Rank operator is available, Table is equivalent to ,⍤¯1
:
(,⍤¯1)2 3 4 2⍴⎕A ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV
In languages where function axis is available, Table is equivalent to ,[1↓⍳≢⍴Y]
:
{,[1↓⍳≢⍴⍵]⍵}2 3 4 2⍴⎕A ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV
History
Table was implemented in SHARP APL release 19.0,[1] 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.[2] 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
Lessons
Documentation
- ↑ Robert Bernecky. An Introduction to Function Rank at APL88. APL Quote Quad, Volume 18, Issue 2. December 1987.
- ↑ F.H.D. van Batenburg. Conformity of APL Implementations to the ISO APL Standard. Vector journal Volume 21, No.3. 2005-05.