


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Greg Humphreys http://www.cs.virginia.edu/~humper CS150: Computer Science University of Virginia Computer Science
CS150 Fall 2005: Lecture 4: Programming with Data 2
CS150 Fall 2005: Lecture 4: Programming with Data (^3) (square 4) Eval^ Rule^ 3a:^ Application Eval Rule 2: Names square (^4) (lambda (x) (* x x)) Eval Rule 1: Primitive 4 Eval^ Rule^ 3b:^ Application Apply Rule 2: Compound Application (* 4 4 ) Eval Rule 3a: Application Eval Rule 1: Primitive ^4 4 Eval Rule 1: Primitive #<primitive:> 4 4 Eval Rule 3b: Application Apply Rule 1: Primitive Application 16 CS150 Fall 2005: Lecture 4: Programming with Data (^4)
Guy Steele co-designed Scheme and created the first Scheme interpreter for his 4 th^ year project More recently, Steele specified Java [1995]
Lists are pretty important – hard to write a useful Scheme program without them.
CS150 Fall 2005: Lecture 4: Programming with Data 7
CS150 Fall 2005: Lecture 4: Programming with Data 8
( cons 1 2) (1. 2)
CS150 Fall 2005: Lecture 4: Programming with Data (^9)
( car ( cons 1 2)) 1 ( cdr ( cons 1 2)) 2
car cdr CS150 Fall 2005: Lecture 4: Programming with Data (^10)
(define (triple a b c) (cons a (cons b c))) (define (t-first t) (car t)) (define (t-second t) (car (cdr t))) (define (t-third t) (cdr (cdr t)))
CS150 Fall 2005: Lecture 4: Programming with Data 19
CS150 Fall 2005: Lecture 4: Programming with Data 20