Cartesian Product

From APL Wiki
Revision as of 02:15, 5 March 2024 by Marshall (talk | contribs) (Created page with "{| class=vertical-navbox style="float:right; font-size:500%; margin:0 1ex;" |<code>{</code> |} '''Cartesian Product''' (<code>{</code>, or <code>@</code> in SAX), '''All''', or '''Catalogue''' is a primitive monadic function that returns an array of all combinations of choices from its argument, much like Outer Product. It appears in Rationalized APL, A Dictionary of APL, SAX, and J. It shares a glyph with the dyadic function Select (l...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
{

Cartesian Product ({, or @ in SAX), All, or Catalogue is a primitive monadic function that returns an array of all combinations of choices from its argument, much like Outer Product. It appears in Rationalized APL, A Dictionary of APL, SAX, and J. It shares a glyph with the dyadic function Select (like bracket indexing), which uses the same all-combinations pattern in the way it handles indices.

The argument to Cartesian Product is a boxed (nested) vector giving a list of arrays. It returns a boxed result whose shape is found by catenating all the argument array shapes, and where each result element contains one element from each argument array. In the following example from A Dictionary of APL, vectors of shapes 2, 2, and 3 (combined with Link) give a result of shape 2 2 3.

   { 'ht'⊃'ao'⊃'gtw'
|¯¯¯||¯¯¯||¯¯¯|
|hag||hat||haw|
|___||___||___|
|¯¯¯||¯¯¯||¯¯¯|
|hog||hot||how|
|___||___||___|

|¯¯¯||¯¯¯||¯¯¯|
|tag||tat||taw|
|___||___||___|
|¯¯¯||¯¯¯||¯¯¯|
|tog||tot||tow|
|___||___||___|

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