Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
57
Task/Zebra-puzzle/Racket/zebra-puzzle.rkt
Normal file
57
Task/Zebra-puzzle/Racket/zebra-puzzle.rkt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#lang racket
|
||||
|
||||
(require racklog)
|
||||
|
||||
(define %select
|
||||
(%rel (x xs S S1)
|
||||
[(x (cons x xs) xs)]
|
||||
[(x (cons S xs) (cons S S1)) (%select x xs S1)]
|
||||
[((cons x xs) S)
|
||||
(%select x S S1)
|
||||
(%select xs S1)]
|
||||
[('() (_))]))
|
||||
|
||||
(define %next-to
|
||||
(%rel (A B C)
|
||||
[(A B C)
|
||||
(%or (%left-of A B C)
|
||||
(%left-of B A C))]))
|
||||
|
||||
(define %left-of
|
||||
(%rel (A B C)
|
||||
[(A B C) (%append (_) (cons A (cons B (_))) C)]))
|
||||
|
||||
(define %zebra
|
||||
(%rel (Owns HS)
|
||||
[(Owns HS)
|
||||
(%is HS (list (list (_) 'norwegian (_) (_) (_))
|
||||
(_)
|
||||
(list (_) (_) (_) 'milk (_))
|
||||
(_) (_)))
|
||||
(%select (list (list 'red 'englishman (_) (_) (_))
|
||||
(list (_) 'swede 'dog (_) (_))
|
||||
(list (_) 'dane (_) 'tea (_))
|
||||
(list (_) 'german (_) (_) 'prince))
|
||||
HS)
|
||||
(%select (list (list (_) (_) 'birds (_) 'pallmall)
|
||||
(list 'yellow (_) (_) (_) 'dunhill)
|
||||
(list (_) (_) (_) 'beer 'bluemaster))
|
||||
HS)
|
||||
(%left-of (list 'green (_) (_) 'coffee (_))
|
||||
(list 'white (_) (_) (_) (_))
|
||||
HS)
|
||||
(%next-to (list (_) (_) (_) (_) 'dunhill)
|
||||
(list (_) (_) 'horse (_) (_))
|
||||
HS)
|
||||
(%next-to (list (_) (_) (_) (_) 'blend)
|
||||
(list (_) (_) 'cats (_) (_))
|
||||
HS)
|
||||
(%next-to (list (_) (_) (_) (_) 'blend)
|
||||
(list (_) (_) (_) 'water (_))
|
||||
HS)
|
||||
(%next-to (list (_) 'norwegian (_) (_) (_))
|
||||
(list 'blue (_) (_) (_) (_))
|
||||
HS)
|
||||
(%member (list (_) Owns 'zebra (_) (_)) HS)]))
|
||||
|
||||
(%which (Who HS) (%zebra Who HS))
|
||||
Loading…
Add table
Add a link
Reference in a new issue