内容 4.4 Logic Programming · 377
练习 自检推理
Exercise 4.61: The following rules implement a
next-to relation that finds adjacent elements of a list:
(rule (?x next-to ?y in (?x ?y . ?u)))
(rule (?x next-to ?y in (?v . ?z))
(?x next-to ?y in ?z))
What will the response be to the following queries?
(?x next-to ?y in (1 (2 3) 4))
(?x next-to 1 in (2 1 3 1))
练习 4.61:以下规则实现了一个 next-to 关系,用于找出表中相邻的元素:
(rule (?x next-to ?y in (?x ?y . ?u)))
(rule (?x next-to ?y in (?v . ?z))
(?x next-to ?y in ?z))
对以下查询的响应分别是什么?
(?x next-to ?y in (1 (2 3) 4))
(?x next-to 1 in (2 1 3 1))
SICP source code scheme
(rule (?x next-to ?y in (?x ?y . ?u)))
(rule (?x next-to ?y in (?v . ?z))
(?x next-to ?y in ?z)) SICP source code scheme
(?x next-to ?y in (1 (2 3) 4))
(?x next-to 1 in (2 1 3 1)) 我的笔记 自动保存