Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
(define (unify a b)
(cond ((and (pair? a)
(pair? b)) (cons (unify (car a) (car b))
(unify (cdr a) (cdr b))))
((symbol? a) b) ; here i just return b, because a symbol matches anything. a more complex system would have a third argument
; , the environment, that tracks existing bindings for a, and prevents conflicts. then, instead of returning b
; we could update the environment with the binding for a = b, or issue a failure (in kanren language, #u)
((eq? a b) b) ; a and b trivially unify without updating any bindings. here I just return their mutual value
(else (error)))) ; nope, that's a #u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.