Cartesian Product
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
- J NuVoc, Dictionary