This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: (minus1 9) ; yields 8functional programming is very powerfulit 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 dotproduct (lambda (u v)) (reduce + (zipper * u v)) ))(define evalline (lambda (x) (lambda (b a) (+ b (* a x)) ))) (define evalpoly (lambda (x) (lambda (l) (reduce (evalline x) 1)))) ((evalpoly 2) (list 5 4 3 2 1)) ; yields 57evalpoly 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, ObjectOriented Programming, Functional Programming, Recursion, Closure, lambda

Click to edit the document details