In my nowadays classes, I learned CPS(continuation passing style). The professor used an example of factorial to explain it:
function fac(n, c) {
return n === 1
? c(n)
: fac(n - 1, x => c(n * x));
}
function factorial_iter(n) {
return fac(n, x => x);
}
disp(factorial(3));
I thought that I may have understood how this code actually runs, but it's still very hard for me to try to write such code using CPS.
I'm looking for some useful learning material in Chinese so that I can have a better understanding of such complicated stuff.
Thank you.
Oh, I is a english men.