Table

From APL Wiki
Jump to navigation Jump to search

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
┌─┬───┐
A5 1
B   
C   
D   
E   
└─┴───┘
      {()}3 4⎕A
┌────┬───┐
ABCD3 4
EFGH   
IJKL   
└────┴───┘
      {()}2 3 4⎕A
┌────────────┬────┐
ABCDEFGHIJKL2 12
MNOPQRSTUVWX    
└────────────┴────┘

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

      {()}123
┌───┬───┐
1231 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

External links

Lessons

Documentation


APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace