2 (:use [clojure.contrib test-is]
11 (average (f (- x dx1))
15 ;; smooth takes a function as argument. repeated takes a function
16 ;; which needs to be repeated. Here it is the smooth function and
17 ;; the number of times it needs to be repeated. We call the function
18 ;; returned by repeated with f.
19 (defn smooth-repeatedly [f n]
20 ((repeated smooth n) f))
22 ;; borrowing an idea from Drew Hess' solutions, we generate a test impulse
24 (defn impulse-maker [x a]
29 ;; we define a function which has an impulse at x=2 with a value 10.
30 (defn my-impulse-func [x]
31 ((impulse-maker 2 10) x))
34 ((smooth my-impulse-func) 2)
36 user> ((smooth my-impulse-func) 1)
38 user> ((smooth (smooth my-impulse-func)) 2)
40 user> ((smooth (smooth (smooth my-impulse-func))) 2)
43 ;; now using our new function
44 ((smooth-repeatedly my-impulse-func 1) 2)
46 user> ((smooth-repeatedly my-impulse-func 2) 2)
48 user> ((smooth-repeatedly my-impulse-func 3) 2)