summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Halloway <stu@thinkrelevance.com>2011-01-09 17:39:11 -0500
committerStuart Halloway <stu@thinkrelevance.com>2011-01-14 08:23:42 -0500
commit15c0f015f723f6c7e8ed3b3c88bb1ecfc01e7980 (patch)
tree401418a6d76e7bf36607ce387ffd41343557076a /src
parent9506ca6e7589599c17e165d6583a9c97aa1ca0c0 (diff)
#710 diff mutable sets
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
Diffstat (limited to 'src')
-rw-r--r--src/clj/clojure/data.clj15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/clj/clojure/data.clj b/src/clj/clojure/data.clj
index f5730016..8f9a027d 100644
--- a/src/clj/clojure/data.clj
+++ b/src/clj/clojure/data.clj
@@ -72,12 +72,19 @@
java.util.Map
(equality-partition [x] :map))
+(defn- as-set-value
+ [s]
+ (if (set? s) s (into #{} s)))
+
(extend-protocol Diff
java.util.Set
- (diff-similar [a b]
- [(not-empty (set/difference a b))
- (not-empty (set/difference b a))
- (not-empty (set/intersection a b))])
+ (diff-similar
+ [a b]
+ (let [aval (as-set-value a)
+ bval (as-set-value b)]
+ [(not-empty (set/difference aval bval))
+ (not-empty (set/difference bval aval))
+ (not-empty (set/intersection aval bval))]))
java.util.List
(diff-similar [a b]