ElegantPairingInt {PPRL} | R Documentation |
Elegant Pairing
Description
Unordered Pairing Function creating a new unique integer from two input integers.
Usage
ElegantPairingInt(int1, int2)
Arguments
int1 |
first integer to be paired. |
int2 |
second integer to be paired. |
Details
With two of non-negative integers x and y as an input, the pairing is computed as:
elegantPairing(x, y) = (x * y) + floor ((|x - y| - 1)^2) / 4)
The function is commutative. x and y have to be non-negative integers.
Value
The function outputs a single non-negative integer that is uniquely associated with that unordered pair.
Source
Szudzik, M. (2006): An Elegant Pairing Function. Wolfram Science Conference NKS 2006.
See Also
Examples
ElegantPairingInt(2, 3)
[Package PPRL version 0.3.8 Index]