Which is the name of the list of all $n^k$ tuples given a $n$ elements set?

41 Views Asked by At

Given a $n$ elements set, which is the name of a list of all $n^k$ tuples ?

e.g. $(n=3, k=2)$:

1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3

This is not a combination of the set $\{1,2,3\}$:

1
2
3
1 2
1 3
2 3
1 2 3

Nor it is a permutation of the set $\{1,2,3\}$:

1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 1 2
3 2 1

And what if the columns have different number of elements ? e.g.

$n(k_1) = 3, n(k_2) = 2$:

1 1
1 2
2 1
2 2
3 1
3 2

A possible implementation in Julia (not necessarily the fastest/most elegant one) would be:

n = [3,2]
data = reshape([[a, b] for a in 1:n[1], b in 1:n[2]], n[1]*n[2])

Do you know if there is there a pre-made function for it ?

2

There are 2 best solutions below

0
On

"All $k$-tuples of $\{1, 2, \ldots, n\}$" is what I have always called it. So your first example would be all $2$-tuples (usually called "ordered pairs") of $\{1, 2, 3\}$.

Your final example would be something like "All $2$-tuples of $\{1, 2, 3\}$ where the second component is not $3$".

0
On

You are listing in lexicographical order the elements of the cartesian product set of $k$ sets of the form $\{1,\ldots,n_i\}$. As Arthur mentioned, the elements of the cartesian product of $k$ sets are usually called $k$-tuples.