Generalization of Cantor Pairing function to triples and n-tuples Is there a generalization for the Cantor Pairing function to (ordered) triples and ultimately to (ordered) n-tuples? It's however important that the there exists an inverse function: computing z from (w, x, y) and also computing w, x and y from z. In other words:


*

*project(w, x, y) = z

*unproject(z) = (w, x, y)


Thinking about it in terms of a three-/n-dimensional coordinate system it should be possible to generalize from ordered pairs to at least ordered triples and most probably also to ordered n-tuples. Is anyone aware of any resources (papers, books, websites...) where such a function is described?

Ok, I think I got it. Your idea is to create recursive functions for both pair and unpair and simply "assemble" the results instead of computing them with an algebraic formula. Of course this works due to the nature of pairing function. If I have time I will add the code in here.
Just one more question: Assuming I actually knew the pairing function for, let's say, triples (or n-tuples). In terms of processing speed on a regular computer, do you think it would be faster than a recursive solution? I assume it would be, because recursion requires to repeatedly create an internal stack for each recursive function call, whereas a mathematical function would just be computed once. So, if it's really about getting the most out of your processor, it would be worth trying to find the algebraic solution to this problem.
