This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
conflict.rkt
61 lines (51 loc) · 1.5 KB
/
conflict.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#lang racket
(require racklog)
; http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_1.html
(define %adjacent
(%rel ()
[('a1 'a2)]
[('a2 'a1)]
[('a1 'a3)]
[('a1 'a4)]
[('a1 'a5)]
[('a2 'a3)]
[('a2 'a4)]
[('a3 'a4)]
[('a4 'a5)]
[('a3 'a1)]
[('a4 'a1)]
[('a5 'a1)]
[('a3 'a2)]
[('a4 'a2)]
[('a4 'a3)]
[('a5 'a4)]))
; check it's working
(%which () (%adjacent 'a1 'a2))
(%which () (%adjacent 'a5 'a3))
(define %color
(%rel ()
[('a1 'red 'a)] [('a1 'red 'b)]
[('a2 'blue 'a)] [('a2 'blue 'b)]
[('a3 'green 'a)] [('a3 'green 'b)]
[('a4 'yellow 'a)] [('a4 'blue 'b)]
[('a5 'blue 'a)] [('a5 'green 'b)]))
;; option A
(define %conflict-a
(%let (X Y Color)
(%rel (Coloring )
[(Coloring)
(%adjacent X Y)
(%color X Color Coloring)
(%color Y Color Coloring)])))
;; option B
(define %conflict-b
(%let (X Y Color)
(%rel (Coloring)
[(Coloring)
(%adjacent X Y)
(%color X Color Coloring)
(%color Y Color Coloring)])))
(%which () (%conflict-a 'a)); expecting #f , got #<procedure>
(%which () (%conflict-a 'b)); expecting '() , got #<procedure>
(%which () (%conflict-b 'a)); expecting #f , got #<procedure>
(%which () (%conflict-b 'b)); expecting '() , got #<procedure>