Half of the test will be on chapter 3, a quarter each on chapters 1 and 2. Questions will be like those on previous midterms. Questions identical to or nearly identical to previous exam questions or to homework problems can be expected. There will be one essay question asking you to compare functional and procedural programming in some aspect. For example, "Discuss the pros and cons of functional programming and progrmming with assignment. Define your terms, explain the issues that make programming easy or hard with each." Chapter I Procedural abstraction - see previous review sheet/test Chapter II Data abstraction - see previous review sheet/test Chapter III - Mutable Data and Time Reading - Chapter 3 except for pages 273-296. (sections 3.3.4 & 3.3.5) The bank account example. If a parent procedure (make-account) returns a child procedure (such as dispatch) defined within it, then the parameters (such as balance) of the parent procedure are part of the environment of the child procedure. They can be changed by the child procedure thru the use of "set!" and are private mutable data objects. Use of set-car! and set-cdr! in implementing queues and stacks. When using set-car! and set-cdr!, one must be aware that the pair being changed may be a part of several lists your program is manipulating. Care must be taken that such changed do not have unwanted effects on other lists. For example: 1. (define x '(1 2 3)) (define y (cons x x)) (set-car! (cdr x) 22) Now what is x and what is y? Use box and arrow diagrams to understand what happens. 2. Define a procedure (make-count-down n). It returns a procedure which decrements a local variable (initial value is n). It returns false, (), if the variable hasn't reached zero, returns true, #t, if it has. For example, after you have defined make-count-down, I could have the following: -> (define counter (make-count-down 3)) Value: counter -> (define (watcher) (if (counter) 'Ka-boom! 'not-yet)) Value: watcher -> (watcher) Value: not-yet -> (watcher) Value: not-yet -> (watcher) Value: Ka-boom! Some more good exercises: set! and local state: 3.1, 3.2, 3.3, 3.4, set-car! and set-cdr!: 3.12, 3.13, 3.14, queues: 3.22, 3.23 Buzzword summary, data structure manipulation functions -- constructors / selectors / recognizers / mutators Concurrency primitives: parallel-execute, serializers, mutex, test-and-set! the problems parallelism creates. The way the primitives are used to solve these problems. Remaining problems: deadlock. Streams can be the basis of standard interfaces between functional modules, can represent infinite objects. This requires the use of delayed evaluation. Primitives: delay and force. Stream primitives: cons-stream, stream-car, stream-cdr, (head, tail). Where is the use of delay and force in these? Some higher operations require the explicit use of delay and force. Use of streams to produce infinite streams such as streams of numbers with certain properties, streams of solutions to the queens problem, streams representing power series.