This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)


Tuples[list, n]
generates a list of all possible n-tuples of elements from list.
Tuples[{list1, list2, ...}]
generates a list of all possible tuples whose i^(th) element is from listi.
  • The elements of list are treated as distinct, so that Tuples[list, n] for a list of length k gives output of length kn.
  • The order of elements in Tuples[list, n] is based on the order of elements in list, so that Tuples[{a1, ..., ak}, n] gives {{a_1,a_1,…,a_1},{a_1,a_1,…,a_2},…,{a_k,a_k,…,a_k}}.
  • Tuples[list, {n1, n2, ...}] generates a list of all possible n_1⨯n_2⨯… arrays of elements in list.
  • The object list need not have head List. The head at each level in the arrays generated by Tuples will be the same as the head of list.
New in 5.1