ambeval-step1 - ;;((self-evaluating? exp) exp) ;; OLD...

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))
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: ;;((self-evaluating? exp) exp) ;; OLD ((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 (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

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at University of California, Berkeley.

Page1 / 2

ambeval-step1 - ;;((self-evaluating? exp) exp) ;; OLD...

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