Shorter versions of Artes' methods:
Tuples @ Range[0, {80, 20}]
Join @@ Array[List, {81, 21}, 0]
Related methods that may be of use:
a = {1, 2, 3, 4};
b = {q, r, s};
Distribute[{a, b}, List]
{{1, q}, {1, r}, {1, s}, {2, q}, {2, r}, {2, s}, {3, q},
{3, r}, {3, s}, {4, q}, {4, r}, {4, s}}
Inner[f, List /@ a, {b}, g]
{{g[f[1, q]], g[f[1, r]], g[f[1, s]]}, {g[f[2, q]], g[f[2, r]],
g[f[2, s]]}, {g[f[3, q]], g[f[3, r]], g[f[3, s]]}, {g[f[4, q]],
g[f[4, r]], g[f[4, s]]}}
Outer[f, a, b]
{{f[1, q], f[1, r], f[1, s]}, {f[2, q], f[2, r], f[2, s]}, {f[3, q],
f[3, r], f[3, s]}, {f[4, q], f[4, r], f[4, s]}}
Notice the different levels preserved and opportunities to apply custom functions in each case. All methods shown have a place.
Also be familiar with the syntax of Table
which is closely related to Do
, Sum
, Product
, etc.
Table[{i, j}, {i, a}, {j, b}]
{{{1, q}, {1, r}, {1, s}}, {{2, q}, {2, r}, {2, s}}, {{3, q},
{3, r}, {3, s}}, {{4, q}, {4, r}, {4, s}}}
Product[i + j, {i, a}, {j, b}]
(1 + q) (2 + q) (3 + q) (4 + q) (1 + r) (2 + r) (3 + r) (4 + r) (1 + s) (2 + s) (3 + s) (4 + s)
Also related is:
KroneckerProduct[a, b]
{{q, r, s}, {2 q, 2 r, 2 s}, {3 q, 3 r, 3 s}, {4 q, 4 r, 4 s}}