2 (:use [sicp utils ex1_37]
3 [clojure.contrib test-is]))
5 (defn gen-sequence [len]
6 (let [l (+ 1 (int (/ len 3)))
7 s1 (map #(* % 2) (range 1 (inc l)))
8 s2 (map (fn [_] 1) (range 1 (inc l)))]
9 (concat [0 1] (interleave s1 s2 s2))))
10 ;; we concat [0 1] because nth sequences are indexed from 0
13 (defn e-approximation [len]
14 (let [l (* 3 (int (/ len 3.0)))
17 (cont-frac (fn [k] 1.0)
22 user> (e-approximation 10)
24 user> (e-approximation 20)
26 user> (e-approximation 40)
28 user> (e-approximation 50)
30 user> (e-approximation 60)
32 user> (e-approximation 100)