Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 27: Review – most children and truth about cons.

Similar presentations


Presentation on theme: "CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 27: Review – most children and truth about cons."— Presentation transcript:

1 CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis colleenL@berkeley.edu Lecture 27: Review – most children and truth about cons

2 Today Generalized List Recursion The truth about cons

3 most-children (define (number-of-most-children tree) (if (leaf? tree) 0 (reduce max (cons (length (children tree)) (map number-of-most-children (children tree) ) ) ) ) )

4 most-children A CB FDD 0 0 0 3 0 0

5 The truth about cons (cons ‘B ‘() )  ‘(B) B‘() carcdr

6 The truth about cons (cons ‘A ‘(B) )  ‘(A B) A carcdr B‘() carcdr

7 The truth about cons (cons ‘A ‘(B C D) )  ‘(A B C D) A carcdr B carcdr C carcdr D‘() carcdr

8 The truth about cons (cons ‘(A) ‘(B) )  ‘((A) B) carcdr B‘() carcdr A‘() carcdr

9 The truth about cons (cons ‘A ‘B)  ‘(A. B) AB carcdr


Download ppt "CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 27: Review – most children and truth about cons."

Similar presentations


Ads by Google