I wrote a function in Clojure to solve quadratic equations using the quadratic formulaThe function(defn solvequadeq [a b c] (let [D (- (* b b) (* 4 a c))]      (if (< D 0) #{}        (let [sqrtD (Math/sqrt D)              x1 (/ (+ (- b) sqrtD) (* 2 a))              x2 (/ (- (- b) sqrtD) (* 2 a))]              (set [x1 x2])))))Unit tests(defn assertFuzzyEquals [act exp]    ;; From codewars.com  (do (println asserting equality over  act exp)  (let [inrange (<= (Math/abs (- act exp)) 1e-2)]    (if (= inrange false)      (println abs(actual - expected) must be <= 1e-2. Expected was  exp  but got:  act))    (is (= inrange true)))))(defn assertSetsFuzzyEqual [act exp]  (and (is (= (count act) (count exp)))  (doall (map assertFuzzyEquals (sort (vec act)) (sort (vec exp))))))   ; (1)(deftest a-test5  (testing Solve quadratic equations          (assertSetsFuzzyEqual (solvequadeq 1 0 0) #{0})          (assertSetsFuzzyEqual (solvequadeq 1 -6 9) #{3})          (assertSetsFuzzyEqual (solvequadeq 1 -4 3) #{1 3})          (assertSetsFuzzyEqual (solvequadeq 1 -4 14) #{})))N.B.: assertFuzzyEquals is borrowed from a task of codewars.com, all the rest is my code.While any remark, and suggestion is welcome, I would be interested most particularly in the following questions:Is using a set a good solution for avoiding having the same return value twice, if the two solutions are equal? (I am worrying that they might not be always exactly equal, due to imprecision in calculation.)If not, than what would be a better approach, to elegantly handle the case of one vs two solutions?Independently whether sets should be used for this particular problem or not, is there a better way to compare two sets for equality, with a custom function between the elements? (C.f., line (1))EDIT: Clarification of this last point, as per the answer of Josh.The question is: what is the best practice, in Clojure, for checking the equality of two sets of floating point numbers?Let's say, that we have a set with values #{1.0, 2.0}, and want to compare it against the set #{1, 2}.Attempted solutions:(= #{1.0, 2.0} #{1, 2}); result false, since 1.0 != 1(reduce #(and %1 %2)  (map #(> 0.01 (Math/abs (- %1 %2))) #{1.0,2.0}  #{2,1})); returns false, since ordering of elements in the set is not guaranteed(reduce #(and %1 %2)  (map #(> 0.01 (Math/abs (- %1 %2))) (sort (vec #{1.0,2.0}))  (sort (vec #{2,1})))); returns true, because fixes the ordering, but is very complicated...So, I am asking if there is a better way, to compare two sets, providing a custom function for equality checking (in this particular case, this custom function would be #(> 0.01 (Math/abs (- %1 %2)))).I am thinking of something like this (pseudo-code only):(sets-equal #(> 0.01 (Math/abs (- %1 %2))) #{1.0,2.0}  #{2,1}
Solving quadratic equation in Clojure
beginner;clojure;floating point