This preview shows page 1. Sign up to view the full content.
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 Pascals 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
- Spring '10