In this guide, we will discuss Clojure subset? Is set1 a subset of set2?
Syntax
Following is the syntax.
(subset? set1 set2)
Parameters − ‘set1’ is the first set of elements. ‘set2’ is the second set of elements.
Return Value − True if set1 is a subset of set2, else false if not.
Example
Following is an example of subset? in Clojure.
(ns clojure.examples.example (:require [clojure.set :as set]) (:gen-class)) (defn example [] (println (set/subset? #{1 2} #{2 3})) (println (set/subset? #{1 2} #{1 2 3}))) (example)
Output
The above code produces the following output.
false true
Next Topic : Click Here
Pingback: Clojure - intersection | Adglob Infosystem Pvt Ltd
Pingback: Clojure - Sets | Adglob Infosystem Pvt Ltd