The following code:
(require '[clojure.set])
(println (clojure.set/difference '("a" "b" "c" "d") '("c" "d" "e" "f")))
gives me the following error:
java.lang.ClassCastException: clojure.lang.PersistentList (repl-1:47)
I don't understand what I'm doing wrong. Shouldn't this print out ("a" "b")?
Those are lists, not sets.
(println (clojure.set/difference #{"a" "b" "c" "d"} #{"c" "d" "e" "f"}))
I think you don't need to require '[clojure.set]
. It seems to be automatically loaded with core. Just starting a repl, and typing the below works (at least for me).
user=> (clojure.set/difference (set '(1 2 3)) (set '(3 4 5)))
\#{1 2}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With