This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: H IERARCHICAL D ATA 7 GEORGE WANG [email protected] Department of Electrical Engineering and Computer Sciences University of California, Berkeley June 30, 2010 1 Review/Clarifications from Last Lecture 1.1 As Printed in Scheme So you may have seen the dot in a pair in Scheme. I want you to know what that means. Scheme always will print a pair as a pair of parentesis with a period in between the car and the cdr . However, this would look really ugly in a list, and therefore, whenever you have a dot followed immediately by an open parens, they ’cancel out’, and you’re left with nothing. Thus, everything that is a proper list will print without periods, which is why you may not have seen them before. In other words, if we do (list 1 2 3) , what we should get under normal rules is (1 . (2 . (3 . ()))) , as opposed to (1 2 3) . 1.2 Lists and Sentences RETRACTION. My TA’s have strongly objected to the characterization that was originally here, and so here’s the final word on that. Lists are NOT sentences, and sentences are NOT lists. We should think about sentences as something completely different from lists. Specifically, we should think about sentences as be- ing an ADT (abstract data type) that is implemented using lists, but doesn’t have to be. We should always respect the abstraction barrier between sentences and lists, by using the sentence constructs (sentence, ev- ery, keep, first, butfirst, etc) only on sentences, and using the list constructs (list, car, cdr, cons, append, etc) only on lists. 1 2 Trees 2.1 The Big Idea Trees are a way we have of representing a hierarchy of information. The obvious example are family trees. You have a matriarch and a patriarch followed by all the descendants. Alternately, we may want to orga- nize a series of information geographically. At the very top, we have the world, but below that we have countries, then states, then cities. We can also decompose arithmetic operations into something much the same way.same way....
View Full Document