Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 38 lines (25 sloc) 0.748 kb
bb2fd308 »
2010-07-19 first commit
1 ;;; Exercise 1.44
2
3 (define dx 0.000001)
4
5 (define (average-three x y z)
6 (/ (+ x y z)
7 3))
8
9 (average-three 3 4 5) ;4 correct
10
11 ;this composition function takes two procedures as arguments
12 ;and implemetns x --> f1(f2(x))
13 (define (compose f1 f2)
14 (lambda (x) (f1 (f2 x))))
15
16 (define (my-function x)
17 (* x x x))
18
19 (define (smooth f)
20 (lambda (x) (average-three (f (- x dx))
21 (f x)
22 (f (+ x dx)))))
23
24 ((smooth my-function) 3)
25
26 (define (repeated proc n)
27 (cond ((= n 0) proc)
28 ((= n 1) proc)
29 (else (compose proc (repeated proc (- n 1))))))
30
31 ((repeated square 4) 5) ;;huzzah this works
32
33 (define (n-folded-smooth f)
34 ((repeated smooth 2) f))
35
36 ((n-folded-smooth my-function) 3)
37
Something went wrong with that request. Please try again.