This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Caltech CS 1  Fall 2008 CS1: Introduction to Computation Midterm Review Caltech CS 1  Fall 2008 Midterm • ... on the web site Real Soon Now • Find linked from CS 1 home page – and in "schedule" section • Due date: Tuesday, November 4, 5 PM – Lab 5 also due Thurs night 2am (Nov. 6) – yes, it sucks Caltech CS 1  Fall 2008 Midterm • Five hour time limit – (it shouldn’t really take five hours) • Closed book, closed interpreter • No references except: – your own labs and TA's comments on them – electronic version of lecture slides – The Scheme standard (R5RS) • No collaboration! Caltech CS 1  Fall 2008 Midterm • Five hour time limit – OK if not consecutive five hours, BUT – cannot go to CS 1 lecture, recitation, etc. between start and finish – shouldn't take more than 4 hours Caltech CS 1  Fall 2008 Submission • Submit electronically, plain text format • Submit to CS1man as an assignment called "midterm" • Don't submit e.g. PDF, Word doc • Make fit into 80 columns – we have to print it out to grade it • Penalties imposed for violating these rules! • OK to use editor which matches parentheses – …as long as it’s not DrScheme… – e.g. emacs, gedit Caltech CS 1  Fall 2008 Grading • Score between 0.0 and 6.0 • No min grading Caltech CS 1  Fall 2008 Midterm structure Four parts to midterm: • 1) Substitution model • 2) Asymptotic time complexity • 3) Recursion and function design • 4) Higherorder procedures and abstraction • Only material through Day 7. • No cons/car/cdr stuff. Caltech CS 1  Fall 2008 Substitution model • Thought process: • 1) Is this a special form? – define , lambda , if , cond , and , or – if so, use evaluation rule for that special form Caltech CS 1  Fall 2008 Substitution model • Thought process: • 2) Otherwise: – evaluate operands – evaluate operator – apply operator to operands Caltech CS 1  Fall 2008 Apply operator to operands • If builtin procedure ( + , * etc.) – just do it • Otherwise, – procedure is a lambda expression – substitute values for variables in argument list of lambda expression, into the body – evaluate the resulting expression Caltech CS 1  Fall 2008 Exception • When do we not substitute values for variables in lambda expression? • Lambda shielding Caltech CS 1  Fall 2008 define • Expect that you evaluate all define s • Even e.g. (define x 2) should be evaluated • Be aware of whether define is sugared or not! – if sugared, you need to explicitly desugar it – if first operand has parens, it’s sugared Caltech CS 1  Fall 2008 define (define x 2) – Obviously not sugared (define f (lambda (x) (* x (+ x 3)))) – First operand doesn’t have parentheses… – Not a sugared lambda expression Caltech CS 1  Fall 2008 define (define (f x) (lambda (y) (* x (+ y 3)))) – Definitely sugared! Desugars to: (define f (lambda (x) (lambda (y) (* x (+ y 3))))) – This function returns another function Caltech CS 1  Fall 2008...
View
Full
Document
This note was uploaded on 09/25/2010 for the course CS 1a taught by Professor Vanier during the Fall '09 term at Caltech.
 Fall '09
 Vanier
 Computer Science

Click to edit the document details