5.2.8

2025-09-14

 

题目

A list can be represented in the lambda-calculus by its function. (OCaml’s name for this function is ; it is also sometimes called .) For example, the list becomes a function that takes two arguments and and returns .What would the representation of be? Write a function cons that takes an element and a list (that is, a fold function) and returns a similar representation of the list formed by prepending to . Write and functions, each taking a list parameter. Finally, write a function for this representation of lists (this is quite a bit harder and requires a trick analogous to the one used to define for numbers).

解答

额外写一个取尾部元素的函数