Documentation Center

  • Trial Software
  • Product Updates

combinat::cartesianProduct

Cartesian product

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

combinat::cartesianProduct(S1, …)

Description

combinat::cartesianProduct(S1, ...) returns the cartesian product of the sets or lists S1, … as a list of lists.

The cartesian product of S1 through Sn consists of all lists of length n whose i-th entry is an operand of the set or list Si, for 1 ≤ in.

Any integer k among the arguments is identified with the set of the first k positive integers.

The ordering of the output is unspecified.

Examples

Example 1

The following calls are equivalent:

combinat::cartesianProduct({1, 2}, {a, b}), 
combinat::cartesianProduct(2, [b, a])

Parameters

S1

Set, list, or nonnegative integer

Return Values

List of lists, each of them having as many operands as there were arguments passed to combinat::cartesianProduct.

Was this topic helpful?