3 ms·
gnosis mentioned that the mentioned code is scheme. FWIW, a Clojure transliteration of the derivation example is pretty trivial if that's the sort of REPL you
by cemerick 14y ago
gnosis mentioned that the mentioned code is scheme. FWIW, a Clojure transliteration of the derivation example is pretty trivial if that's the sort of REPL you happen to have close at hand:
=> (def dx 0.0001)
#'user/dx
=> (defn deriv
[f]
(fn [x]
(/ (- (f (+ x dx)) (f x))
dx)))
#'user/deriv
=> (defn cube [x] (* x x x))
#'user/cube
=> (def cube-deriv (deriv cube))
#'user/cube-deriv
=> (cube-deriv 2)
12.000600010022566
=> (cube-deriv 3)
27.00090001006572
=> (cube-deriv 4)
48.00120000993502