5.2.11

2025-09-14

 

题目

Use and the encoding of lists from Exercise 5.2.8 to write a function that sums lists of Church numerals.

解答

第一次写出了这个答案:

然而,由于

这里不存在常见编程语言的短路特性,由于求值策略是 call-by-value,必须先计算 才能应用,也就是最内层 时会对 求值,产生错误。

因此,使用 - 展开,改为:

这样,所有分支都不会提前求值,直到被选择并应用于