ambeval-step2 - (mc-eval (caddr exp) success fail2)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
(define (input-loop next-try) (display "=61A=> ") (flush) (let ((input (read))) (cond ((equal? input 'exit) (print "Au Revoir!")) ((equal? input 'choose-another) (next-try)) (else (begin (print "Starting new problem:") (mc-eval input (lambda (val fail) (print val) (input-loop fail)) (lambda () (print "There are no more choices.") (start-loop)))))))) (define (start-loop) (input-loop (lambda () (print "There is no current problem.") (start-loop)))) (define (mc-eval exp success fail) (cond ((self-evaluating? exp) (success exp fail)) ;;((self-evaluating? exp) exp) ;; OLD ((if-exp? exp) (mc-eval (cadr exp) (lambda (val fail2) (if (not (eq? val 'nay))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (mc-eval (caddr exp) success fail2) (mc-eval (cadddr exp) success fail2))) fail)) ((choose-exp? exp) (eval-choose (cdr exp) success fail)) (else (error "UNKNOWN expression")))) (define (self-evaluating? exp) (or (number? exp) (eq? exp 'aye) (eq? exp 'nay))) (define (if-exp? exp) (eq? (car exp) 'if)) (define (choose-exp? exp) (and (list? exp) (eq? (car exp) 'choose))) (define (eval-choose exps success fail) (if (null? exps) (fail) (mc-eval (car exps) (lambda (val fail2) (success val fail2)) (lambda () (eval-choose (cdr exps) success fail))))) (start-loop)...
View Full Document

Page1 / 2

ambeval-step2 - (mc-eval (caddr exp) success fail2)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online