clojure.set/subset?¶
Is set1 a subset of set2?
Examples¶
Note by arkdrag¶
Do note that this will only work as expected for sets. subset? uses contains? in it's implementation. The functionality in contains? for vectors can be slightly unintuitive at first, and causes functions like this to perform in completely unexpected ways when using vectors instead of sets. For example,
It is slightly more intuitive with maps, as it checks whether every item in the first collection is a key in the map passed in as the 2nd parameter, but still is probably a bit confusing to someone reading your code.
user> (clojure.set/subset? '(7 8) {8 1 7 3})
true
user> (clojure.set/subset? '(9 10) {8 1 7 3})
false
Long story short, if you're using functions from the clojure.set namespace, make sure you're passing in sets.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.