Unformatted text preview: and another subproblem for the rest of the sentence. This second subproblem is just like the original problem, but for a smaller sentence. We can take pigl from last lecture and use it to translate a whole sentence into Pig Latin: (define (pigl-sent s) (if (empty? s) ’() (se (pigl (first s)) (pigl-sent (bf s))))) The structure of pigl-sent is a lot like that of argue . This common pattern is called mapping a function over a sentence. Not all recursion follows this pattern. Each element of Pascal’s triangle is the sum of the two numbers above it: (define (pascal row col) (cond ((= col 0) 1) ((= col row) 1) (else (+ (pascal (- row 1) (- col 1)) (pascal (- row 1) col) )))) 270...
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