Look for Materials of CPS
  • 板块学术版
  • 楼主迟暮天复明心華
  • 当前回复8
  • 已保存回复8
  • 发布时间2025/7/3 22:43
  • 上次更新2025/7/4 17:32:30
查看原帖
Look for Materials of CPS
222865
迟暮天复明心華楼主2025/7/3 22:43

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.

2025/7/3 22:43
加载中...