]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex2_14.clj
rewrite `quote->cons' using `match'.
[sicp.git] / src / sicp / ex2_14.clj
1 (ns sicp.ex2_14
2   (:use [sicp ch2_1_extended ex2_12 ex2_7]))
3
4 (def r1 (make-center-percent 100 5))
5 (def r2 (make-center-percent 500 5))
6
7 (par1 r1 r2)
8 ;;=> (71.62698412698413 96.71052631578948)
9 (par2 r1 r2)
10 ;;=> (79.16666666666667 87.49999999999999)
11
12 (def r4 (make-center-percent 500 1))
13 (def r3 (make-center-percent 1000 1))
14
15 (div-interval r3 r4)
16 ;;=> (1.9603960396039604 2.04040404040404)
17
18 (div-interval  r4 r4)
19 ;;=> (0.9801980198019802 1.02020202020202)
20
21 (div-interval r4 r3)
22 ;;=> (0.4900990099009901 0.51010101010101)
23
24 (percentage (div-interval r4 r3))
25 ;;=> 1.999800019998008
26
27 (percentage (div-interval r3 r3))
28 ;;=> 1.999800019998008
29 (center (div-interval r3 r3))
30 ;;=> 1.000200020002