Chapter 4, Metalinguistic Abstraction

Exercise 4.61


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
;;; Query input:
(?x next-to ?y in (1 (2 3) 4))

;;; Query results:
((2 3) next-to 4 in (1 (2 3) 4))
(1 next-to (2 3) in (1 (2 3) 4))

;;; Query input:
(?x next-to 1 in (2 1 3 1))

;;; Query results:
(3 next-to 1 in (2 1 3 1))
(2 next-to 1 in (2 1 3 1))

;;; Query input:

Note that we can speculate from the last two output that search happens in depth first search order.