This preview shows page 1. Sign up to view the full content.
Unformatted text preview: overall answer; you want to take the union of those sets, and that’s what append does. • Lists vs. sentences. We started out the semester using an abstract data type called sentence that looks a lot like a list. What’s the diFerence, and why did we do it that way? Our goal was to allow you to create aggregates of words without having to think about the structure of their internal representation (i.e., about pairs). We do this by deciding that the elements of a sentence must be words (not sublists), and enforcing that by giving you the constructor sentence that creates only sentences. Example: One of the homework problems this week asks you to reverse a list. You’ll see that this is a little tricky using cons , car , and cdr as the problem asks, but it’s easy for sentences: (define (reverse sent) (if (empty? sent) ’() (se (reverse (bf sent)) (first sent)) )) 288...
View Full Document
This note was uploaded on 02/17/2010 for the course COMPUTER S 26275 taught by Professor Harvey,b during the Spring '10 term at Berkeley.
- Spring '10