Refactoring
This commit is contained in:
parent
fd1d3682f3
commit
a457194e11
|
@ -10,7 +10,8 @@
|
|||
"timing.rkt")
|
||||
|
||||
(#%provide ambeval
|
||||
driver-loop)
|
||||
amb-driver-loop
|
||||
amb-eval-program)
|
||||
|
||||
(define (amb? exp) (tagged-list? exp 'amb))
|
||||
(define (amb-choices exp) (cdr exp))
|
||||
|
@ -192,20 +193,11 @@
|
|||
(define input-prompt ";;; Amb-Eval input:")
|
||||
(define output-prompt ";;; Amb-Eval value:")
|
||||
|
||||
(define (driver-loop)
|
||||
(define (amb-driver-loop)
|
||||
(define env (setup-environment))
|
||||
;; Need to pass success and failure continuations to ambeval, so
|
||||
;; will probably need a different eval-program.
|
||||
(eval-program amb-utilities-program
|
||||
(lambda (exp env) ; Evaluate exp using ambeval
|
||||
; passing in appropriate
|
||||
; continuations
|
||||
(ambeval exp
|
||||
env
|
||||
(lambda (value fail) value)
|
||||
(lambda () 'failed)))
|
||||
user-print
|
||||
env)
|
||||
(amb-eval-program-in-env amb-utilities-program env)
|
||||
(define (internal-loop try-again)
|
||||
(prompt-for-input input-prompt)
|
||||
(let ((input (read)))
|
||||
|
@ -226,12 +218,12 @@
|
|||
(announce-output
|
||||
";;; There are no more values of")
|
||||
(user-print input)
|
||||
(driver-loop)))))))
|
||||
(amb-driver-loop)))))))
|
||||
(internal-loop
|
||||
(lambda ()
|
||||
(newline)
|
||||
(display ";;; There is no current problem")
|
||||
(driver-loop))))
|
||||
(amb-driver-loop))))
|
||||
|
||||
|
||||
|
||||
|
@ -252,7 +244,21 @@
|
|||
(make-combination (make-lambda (map let-var bindings)
|
||||
(let-body exp))
|
||||
(map let-val bindings))))
|
||||
|
||||
|
||||
(define (amb-eval-program-in-env program env)
|
||||
(eval-program program
|
||||
(lambda (exp env)
|
||||
(ambeval exp
|
||||
env
|
||||
(lambda (value fail) value)
|
||||
(lambda () 'failed)))
|
||||
user-print
|
||||
env))
|
||||
|
||||
(define (amb-eval-program program)
|
||||
(define env (setup-environment))
|
||||
(amb-eval-program-in-env amb-utilities-program env)
|
||||
(amb-eval-program-in-env program env))
|
||||
|
||||
|
||||
'AMB-EVALUATOR-LOADED
|
||||
|
|
Loading…
Reference in New Issue