On Sat, 10 Mar 2018 11:15:49 +0000, Paul Moore wrote: > On 10 March 2018 at 02:18, MRAB <pyt...@mrabarnett.plus.com> wrote: [...] >> This might help, although the order they come out might not be what you >> want: >> >> def triples(): >> for total in itertools.count(1): >> for i in range(1, total): >> for j in range(1, total - i): >> yield i, j, total - (i + j) > > Mathematically, that's the usual generalisation of Cantor's diagonal > argument.
Thanks MRAB. Paul, do you have a reference for that? Wolfram Mathworld is not very helpful regarding generalising Cantor's diagonalisation pairing function. (It's not the diagonal argument, that's something else :-) -- Steve -- https://mail.python.org/mailman/listinfo/python-list