~ashton314/microKanren

9bf4bc10d410f255b72afb6f6ec0f172ea3449fc — Ashton Wiersdorf 6 months ago d8c20d5
Add playground
1 files changed, 23 insertions(+), 0 deletions(-)

A relations_playground.rkt
A relations_playground.rkt => relations_playground.rkt +23 -0
@@ 0,0 1,23 @@
#lang racket/base

(require "kanren.rkt")

(define (parent c p)
  (conde
   [(== c 'teddy) (== p 'saraih)]
   [(== c 'andrew) (== p 'steve)]
   [(== c 'steve) (== p 'bill)]
   [(== c 'anne) (== p 'john)]
   [(fresh (s) (married p s) (parent c s))]
   [(fresh (s) (married s p) (parent c s))]))

(define (married h w)
  (conde
   [(== h 'steve) (== w 'anne)]
   [(== h 'bill) (== w 'katie)]
   [(== h 'john) (== w 'kitty)]
   [(== h 'andrew) (== w 'saraih)]))

(define (grandparent g s)
  (fresh (p) (parent g p) (parent p s)))