Table: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
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>⍪</source> 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]] <source lang=apl inline>⍪</syntaxhighlight> with the dyadic function [[catenate|Catenate First]].


== Examples ==
== Examples ==
Line 25: Line 25:
│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:
Line 34: Line 34:
│123│1 1│
│123│1 1│
└───┴───┘
└───┴───┘
</source>
</syntaxhighlight>


== Properties ==
== Properties ==
Line 51: Line 51:
ABCDEFGHIJKLMNOPQRSTUVWX
ABCDEFGHIJKLMNOPQRSTUVWX
YZABCDEFGHIJKLMNOPQRSTUV
YZABCDEFGHIJKLMNOPQRSTUV
</source>
</syntaxhighlight>


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


== External links ==
== External links ==

Revision as of 10:49, 11 September 2022

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 First.

Examples

For arrays of rank 1 or higher, the result is identical to applying Ravel to major cells:

<source lang=apl>

     {⍵(⍴⍵)}⍪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│ │ └────────────┴────┘ </syntaxhighlight>

A scalar argument is converted to a 1-by-1 matrix:

<source lang=apl>

     {⍵(⍴⍵)}⍪123

┌───┬───┐ │123│1 1│ └───┴───┘ </syntaxhighlight>

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: <source 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 is available, Table is equivalent to <source lang=apl inline>,⍤¯1</syntaxhighlight>: <source lang=apl>

     (,⍤¯1)2 3 4 2⍴⎕A

ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV </syntaxhighlight> In languages where function axis is available, Table is equivalent to <source lang=apl inline>,[1↓⍳≢⍴Y]</syntaxhighlight>: <source lang=apl>

     {,[1↓⍳≢⍴⍵]⍵}2 3 4 2⍴⎕A

ABCDEFGHIJKLMNOPQRSTUVWX YZABCDEFGHIJKLMNOPQRSTUV </syntaxhighlight>

External links

Lessons

Documentation


APL built-ins [edit]
Primitives (Timeline) Functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare RootRound
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentityStopSelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndexCartesian ProductSort
Selector Index generatorGradeIndex OfInterval IndexIndicesDealPrefix and suffix vectors
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-BeamSpawnFunction axisIdentity (Null, Ident)
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Withe, Atop, Over) ∙ Inner ProductDeterminantPowerAtUnderRankDepthVariantStencilCutDirect definition (operator)Identity (Lev, Dex)
Quad names Index originComparison toleranceMigration levelAtomic vector