Imagine two positive integers A and B. I want to combine these two into a single integer C.
There can be no other integers D and E which combine to C. So combining
For positive integers as arguments and where argument order doesn't matter:
Here's an unordered pairing function:
= x * y + trunc((|x - y| - 1)^2 / 4) =
For x ≠ y, here's a unique unordered pairing function:
= if x < y:
x * (y - 1) + trunc((y - x - 2)^2 / 4)
if x > y:
(x - 1) * y + trunc((x - y - 2)^2 / 4)
=