Created
November 16, 2019 19:54
-
-
Save chelseatroy/755e119ba488b246f766402882df053f to your computer and use it in GitHub Desktop.
amb procedures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (amb? sexp) | |
(and (pair? sexp) (eq? (car sexp) 'amb))) | |
(define (amb-choices sexp) (cdr sexp)) | |
(define (seval-amb sexp succeed fail env) | |
(define (try-next choices) | |
(if (null? choices) | |
(fail) | |
(seval (car choices) succeed | |
(lambda () (try-next (cdr choices))) env) | |
) | |
) | |
(try-next (amb-choices sexp)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment