灯下 登录
计算机科学 / SICP / 4.4.1 Deductive Information Retrieval

Exercise 4.62 · 习题

Exercise 4.62: Define rules to implement the

last-pair operation of Exercise 2.17, which returns a list

containing the last element of a nonempty list. Check your rules on queries

such as (last-pair (3) ?x), (last-pair (1 2 3) ?x) and

(last-pair (2 ?x) (3)). Do your rules work correctly on queries such as

(last-pair ?x (3))?

练习 4.62:定义规则以实现练习 2.17 中的 last-pair 操作,该操作返回包含非空表最后一个元素的表。在如 (last-pair (3) ?x)、(last-pair (1 2 3) ?x) 和 (last-pair (2 ?x) (3)) 等查询上检验你的规则。你的规则对 (last-pair ?x (3)) 这样的查询能否正确工作?