Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #lang racket
- (require racklog)
- (define %edge
- (%rel ()
- [('a 'b)]
- [('a 'g)]
- [('b 'c)]
- [('c 'a)]))
- (define %select
- (%rel (x xs y ys)
- [(x (cons x xs) xs)]
- [(y (cons x xs) (cons x ys))
- (%select y xs ys)]))
- (define %hamilton
- (%rel (x xs y z zs)
- [(x (list y x))]
- [(x (cons x (cons z xs)))
- (%or
- (%edge x z)
- (%edge z x))
- (%hamilton x (cons z xs))]
- [(x (cons y (cons z xs)))
- (%not (%select y xs zs))
- (%not (%= x z))
- (%or
- (%edge y z)
- (%edge z y))
- (%hamilton x (cons z xs))]))
- (eq? (%which () (%hamilton 'a '(a b c a))) '())
- (eq? (%which () (%hamilton 'a '(a b a g a))) #f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement