]> git.rkrishnan.org Git - sicp.git/commitdiff
added approx-equal function
authorRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Mon, 7 Jun 2010 12:08:11 +0000 (17:38 +0530)
committerRamakrishnan Muthukrishnan <vu3rdd@gmail.com>
Mon, 7 Jun 2010 12:08:11 +0000 (17:38 +0530)
src/sicp/utils.clj

index f5c3e9c6f04397a2466d1b7dc9760ad1d41e4ed1..258ac6080cb2b19e170c13cb04fcc4da42f48e24 100644 (file)
@@ -39,6 +39,9 @@
   (/ (reduce + coll)
      (float (count coll))))
 
+(defn approx-equal [x y]
+  (< (abs (- x y)) 0.00001))
+
 (defmacro microbench
   " Evaluates the expression n number of times, returning the average
     time spent in computation, removing highest and lowest values.