dd.sets.fw - (if result (what-if-found (cadr result))...

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

View Full Document Right Arrow Icon
; ***** ; Functions that implement data-directed programming (from Concrete Abstractions). (define (make-type name operation-table) (cons name operation-table) ) (define type-name car) (define type-operation-table cdr) (define (operate operation-name value) (table-find (type-operation-table (type value)) operation-name (lambda (procedure) (procedure (contents value))) (lambda ( ) (error "No way of doing operation on type" operation-name (type-name (type value)) ) ) ) ) (define (make-table keys values) (map list keys values) ) (define (table-find table key what-if-found what-if-not) (let ((result (assoc key table)))
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: (if result (what-if-found (cadr result)) (what-if-not)) ) ) ; ***** ; Set up of types for data-directed programming. (define list-set-type (make-type 'list ... ) ) (define intvls-set-type (make-type 'intvls ... ) ) ; ***** ; Generic operations on sets. (define (member? x set) ((operate 'member? set) x) ) (define (with-element x set) ((operate 'with-element set) x) ) (define (elements set) ((operate 'elements set)) ) ; ***** ; Utility functions. (define (find-if p L) (cond ((null? L) #f) ((p (car L)) (car L)) (else (find-if p (cdr L))) ) )...
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

dd.sets.fw - (if result (what-if-found (cadr result))...

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