concept disj in category clojure

appears as: disj, disj
Clojure: The Essential Reference

This is an excerpt from Manning's book Clojure: The Essential Reference.

(defn valid? [allowed values]
  (empty?
    (apply disj (set values) allowed))) ; #1

(def allowed [:a :b :c])

(valid? allowed [:c :c 1 :a]) ; #2
;; false

(valid? allowed [:c :c :a]) ; #3
;; true
  • conj is the opposite of disj, but disj is not polymorphic like conj and only works on sets.
  • difference is another option to remove multiple items from a set. difference takes the items to remove grouped in a set, while disj accepts them as distinct arguments.
  • There are other functions in the standard library that would benefit from transient. The book illustrated the use of transient to improve the performance of: zipmap, merge, tree-seq, disj and select-keys. We also used transient in: