Question

How can I use clojure.set in ClojureScript?

I always get a error.

(def middle-land (set (for [x water-hor
                            y (vec (clojure.set/difference (set (range 0 board-side))
                                                           (set water-ver)))]
                    [x y])))

ReferenceError: clojure is not defined
Was it helpful?

Solution

Seems you need to explicitly require the namespace to be able to use it:

ClojureScript:cljs.user> (ns core (:require clojure.set))
ClojureScript:core> (clojure.set/difference #{1 2} #{1 4}) ;=> #{2}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top