Out of simple curiosity and desire to deepen my understanding of the CPS style (continuation passing style), I would like to know if there is a way to rewrite this function according to this scheme.
The difficulty probably lies in the design of the continuation, usually a continuation only takes one argument, but in this case it should take two, right?
Here is the function I want to practice:
long int ack(int m, int n)
{
if (!m) return n + 1;
if (!n) return ack(m - 1, 1);
return ack(m - 1, ack(m, n - 1));
}
If this "is not possible", is there another relatively similar non-trivial means?