- with-require procedures receive-envprocedure
Installs require, an-element-of, an-integer-starting-from in the environment in addition to the primitive procedures enumerated in procedures; then calls receive-env with the configured environment.
- procedures
- A key-value list of primitive procedure-names and their definitions
- receive-env
- A lambda of one value that is called with the prepared environment
(define (with-require procedures receive-env) (with-primitive-procedures (append procedures `((member ,member) (not ,not))) (lambda (env) (ambeval* '(define (require p) (if (not p) (amb) 'success)) env) (ambeval* '(define (an-element-of items) (require (not (null? items))) (amb (car items) (an-element-of (cdr items)))) env) (ambeval* '(define (an-integer-starting-from n) (amb n (an-integer-starting-from (+ n 1)))) env) (ambeval* '(define (distinct? items) (cond ((null? items) true) ((null? (cdr items)) true) ((member (car items) (cdr items)) false) (else (distinct? (cdr items))))) env) (receive-env env))))