proj4a - ; CS 61A project 4 part I solutions ; Problem A1...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 (define-class (line-obj text) (method (next) (let ((result (car text))) (set! text (cdr text)) result)) (method (empty?) (null? text)) (method (put-back token) (set! text (cons token text))) ) (define (make-line-obj text) (instantiate line-obj text)) (define (logo-type val) (define (print-one val) (cond ((list? val) (display "[") (if (pair? val) (logo-type val)) (display "]")) (else (display val)))) (define (iter val) (print-one (car val)) (cond ((null? (cdr val)) '()) (else (display " ") (iter (cdr val))))) (cond ((null? val) '()) ((list? val) (iter val)) (else (print-one val))) '=no-value=) (define (eval-line line-obj env) (if (ask line-obj 'empty?)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Sheet1 Page 2 '=no-value= (let ((value (logo-eval line-obj env))) (if (eq? value '=no-value=) (eval-line line-obj env) value)))) (define (logo-pred pred) (lambda args (if (apply pred args) true false))) (define (eval-prefix line-obj env) (define (eval-helper paren-flag) (let ((token (ask line-obj 'next))) (cond ((self-evaluating? token) token) ... (else (let ((proc (lookup-procedure token))) (if (not proc) (error "I don't know how to" token)) (IF (LIST? (ARG-COUNT PROC)) (LOGO-APPLY PROC
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

proj4a - ; CS 61A project 4 part I solutions ; Problem A1...

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

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