move form deftype to defrecord for easier set comparison

deftype gives different object instances which causes comparisons
of sets with different instances to fail, as it check the instance
equality instead of value equality, which can be provided by
using defrecord instead of deftype
This commit is contained in:
2026-01-11 16:17:50 -06:00
parent d0c78810f0
commit 211efb5d16

View File

@@ -3,7 +3,7 @@
[clojure.test :refer [deftest testing is]]
[challenge.discrete-value-range :as range]))
(deftype IntInclusiveDiscreteValueRange
(defrecord IntInclusiveDiscreteValueRange
[^int start ^int end]
range/DiscreteValueRange
(abuts [_this other]
@@ -29,13 +29,10 @@
Object
(toString [_this]
(str start ".." end))
(equals [_this other]
(and (= start (.start other))
(= end (.end other)))))
(str start ".." end)))
(defn int-range-inclusive [start end]
(assert (<= start end))
(assert (<= start end) (str "start : " start "; end: " end))
(->IntInclusiveDiscreteValueRange start end))
(defmethod range/->discrete-value-range :int-range-inclusive [_ start end]