lecture 03 -- Recursive Procedures - Copy

lecture 03 -- Recursive Procedures - Copy - A more complex...

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

View Full Document Right Arrow Icon
10/19/2010 1 T. METIN SEZGIN OCT 11 2010 Lecture 3 Auxiliary Procedures Variables Implement occurs-free? Such that The rules of occurs-free? How do we go about the implementation? How do we go about the implementation? The grammar The procedure What do we do with occurs-free? What good is it? Any ideas of sample scenarios for occurs-free? How about application expressions? (E 1 E 2 ) ((lambda (x) (* x x)) 5) Only if we had a way of substituting values
Background image of page 1

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

View Full DocumentRight Arrow Icon
10/19/2010 2 subst How do we go about the implementation? How do we go about the implementation? The grammar The procedure How do we go about the implementation? The grammar The procedure How do we go about the implementation? The grammar The procedure How do we go about the implementation? The grammar The procedure
Background image of page 2
10/19/2010 3 Things to note The procedures are mutually recursive The trick of decomposing procedures for each syntactic type is important Simplifies our design Take home message Follow the Grammar
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: A more complex example Consider the procedure number-elements This procedure should take a list (v v 1 v 2 …) and return ( (0 v ) (1 v 1 ) …)) . Remember the grammar The problem No obvious way to build (number-elements lst) from (number-elements (cdr lst)) The solution Implement something more general Implement number-elements-from number-elements-from How are the arguments different? What purpose do they serve? Input list Context argument (inherited attribute) The take home message Follow the grammar When following the grammar doesn’t help… Generalize Another example Consider list-sum How about vector sum? You can’t take cdr of vectors! 10/19/2010 4 How do we go about the implementation? Follow the grammar When following the grammar doesn’t help… Generalize vector-sum Problem set 0 EOPL Exercises 1.1, 1.4, 1.6, 1.12, 1.21, 1.26, 1.34, 1.36...
View Full Document

Page1 / 4

lecture 03 -- Recursive Procedures - Copy - A more complex...

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

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