= Solution
Enumerate finite shells of constant coordinate sum:
``
triples :: [(Integer, Integer, Integer)]
triples =
[(a, b, k-a-b) |
k <- [0..],
a <- [0..k],
b <- [0..k-a]]
``
Here <natural numbers> include zero. Every generated coordinate is nonnegative. Conversely, a given triple $(a,b,c)$ occurs in exactly the shell $k=a+b+c$ and at exactly those loop indices $a,b$. Each shell contains only finitely many triples, so every triple is reached after finitely many earlier outputs. This is <fair enumeration>, unlike nesting three unrestricted infinite lists. For the positive-integer convention, add one to each generated coordinate.
Back to article page