-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathExercise_4_68.rkt
More file actions
24 lines (20 loc) · 636 Bytes
/
Copy pathExercise_4_68.rkt
File metadata and controls
24 lines (20 loc) · 636 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#lang racket/base
(assert! (rule (append-to-form () ?y ?y)))
(assert! (rule (append-to-form (?u . ?v) ?y (?u . ?z))
(append-to-form ?v ?y ?z)))
(assert! (rule (reverse () ())))
(assert! (rule (reverse (?x . ?y) ?z)
(and (reverse ?y ?w)
(append-to-form ?w (?x) ?z))))
;; change order
(assert! (rule (reverse (?x . ?y) ?z)
(and (append-to-form ?w (?x) ?z)
(reverse ?y ?w))))
(reverse (1 2 3) ?x)
;;; Query results:
(reverse (1 2 3) (3 2 1))
(reverse ?x (1 2 3))
;; can't complete
;; swap and rule order:
;;; Query results:
(reverse (3 2 1) (1 2 3))