# Is there any simpler way to generate dominoes?

I want to make a list of dominoes. My attempt is as follows.

Subsets[#, {2}]~Join~Thread[{#, #}] &@Range[0, 6]


{{0,1},{0,2},{0,3},{0,4},{0,5},{0,6},{1,2},{1,3},{1,4},{1,5},{1,6},{2,3},{2,4},{2,5},{2,6},{3,4},{3,5},{3,6},{4,5},{4,6},{5,6},{0,0},{1,1},{2,2},{3,3},{4,4},{5,5},{6,6}}

Is there any simpler way to generate dominoes?

0~Range~6~Subsets~{1, 2} /. {a_} :> {a, a}

{{0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6},
{0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6},
{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6},
{2, 3}, {2, 4}, {2, 5}, {2, 6},
{3, 4}, {3, 5}, {3, 6},
{4, 5}, {4, 6},
{5, 6}}


Also

 0~Range~6~Tuples~2//Map@Sort//Union

{{0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6},
{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6},
{2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6},
{3, 3}, {3, 4}, {3, 5}, {3, 6},
{4, 4}, {4, 5}, {4, 6},
{5, 5}, {5, 6},
{6, 6}}


and

f = If[# <= #2, {##}, Nothing] &;
Join @@ Array[f, {7, 7}, 0]


same result

• I believe you will provide me with more than one solution as usual. Aug 16, 2021 at 20:08
• As an alternative to //Map@Sort//Union you could also use //DeleteDuplicatesBy@Sort Aug 16, 2021 at 21:16

A Table-full way:

Flatten[Table[{j, i}, {i, 0, 6}, {j, 0, i}], 1] // Sort

• Catenate@Table[{r, k}, {r, 0, 6}, {k, r, 6}]
– Alan
Aug 16, 2021 at 23:19