This** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
**Unformatted text preview: **(minus1 9) ; yields 8-functional programming is very powerful-it is harder to understand line by line, but there is much more meaning line by line -(reduce f (list a b c d)) gives (f a (f b (f c d)))) (reduce + (list 1 2 3 4 5)) ; yields 15 (zip * (list 1 2 3) (list 4 5 6)) is the same as (list (* 1 4) (* 2 5) (* 3 6))-define dot-product (lambda (u v)) (reduce + (zipper * u v)) ))-(define eval-line (lambda (x) (lambda (b a) (+ b (* a x)) ))) (define eval-poly (lambda (x) (lambda (l) (reduce (eval-line x) 1)))) ((eval-poly 2) (list 5 4 3 2 1)) ; yields 57-eval-poly 2 claims that any polynomial can be evaluated at the point 2 -reduce (lambda (b a) a*x+b) ' (5 4 3 2 1))-reduce is a combining operator -map puts stuff onto lots of stuff...

View
Full Document

- Spring '14
- StevenWatt
- Computer Science, Object-Oriented Programming, Functional Programming, Recursion, Closure, lambda