cprint { sclass f_ackermann implements VStack.Computable { BigInt a, b; int currentStep; // 0 in the beginning, goes up to 1 *(BigInt *a, BigInt *b) {} void step(VStack stack, O subComputationResult) { if (currentStep == 0) { if (a.equals(BigInt.ZERO)) stack._return(plus(b, BigInt.ONE)); else if (b.equals(BigInt.ZERO)) stack.tailCall(new f_ackermann(a.subtract(BigInt.ONE), BigInt.ONE); else { stack.push(new f_ackermann(a, minus(b, BigInt.ONE))); currentStep = 1; } } else if (currentStep == 1) stack.tailCall(new f_ackermann(minus(a, BigInt.ONE), subComputationResult/BigInt)); else fail(); } } start-thread { print("Result: " + vStackComputeWithStats(new f_ackermann(bigInt(2), bigInt(2)))); } }