Back
set? (clj)
(source)function
(set? x)
Returns true if x implements IPersistentSet
Examples
clojure/core.typed
(ns clojure.core.typed.annotator.debug-macros
(:require [clojure.core.typed.annotator.util :refer [*debug*
*debug-depth*
current-time]])
)
(defmacro debug-when [state msg]
`(when (and (set? *debug*)
(contains? *debug* ~state))
(let [msg# ~msg]
(println)
(println (str "SQUASH ITERATION:\n" msg#)))))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
"Type annotations for the base Clojure distribution."
#?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
(:require [clojure.core :as cc]
[typed.clojure :as t]
#?(:clj [typed.ann-macros.clojure :as macros])
#?(:clj typed.ann.clojure.jvm) ;; jvm annotations
#?(:clj clojure.core.typed))
#?(:clj
(:import (clojure.lang PersistentHashSet PersistentList
APersistentMap #_IPersistentCollection
#_ITransientSet
IRef)
(java.util Comparator Collection))))
cc/seq? (t/Pred (t/Seq t/Any))
cc/set? (t/Pred (t/Set t/Any))
cc/vector? (t/Pred (t/Vec t/Any))
cc/nil? (t/Pred nil)
#?@(:cljs [
cc/undefined? (t/Pred t/JSundefined)
])
cc/false? (t/Pred false)
cc/true? (t/Pred true)
cc/symbol? (t/Pred t/Sym)
cc/keyword? (t/Pred t/Keyword)
cc/map? (t/Pred (t/Map t/Any t/Any))
cc/boolean? (t/Pred t/Bool)
cc/any? [t/Any :-> true]
cc/record? (t/Pred #?(:clj clojure.lang.IRecord
:cljs cljs.core/IRecord))
clojure.set/subset? [(t/Set t/Any) (t/Set t/Any) :-> t/Bool]
clojure.set/superset? [(t/Set t/Any) (t/Set t/Any) :-> t/Bool]
clojure.set/join [(t/Set (t/Map t/Any t/Any)) (t/Set (t/Map t/Any t/Any)) (t/? (t/Map t/Any t/Any)) :-> (t/Set (t/Map t/Any t/Any))]
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.ordered-set
(:require [clojure.core.reducers :as r :refer [coll-fold]]
[clojure.set]
[com.dean.interval-tree.tree.node :as node]
[com.dean.interval-tree.tree.order :as order]
[com.dean.interval-tree.tree.protocol :as proto]
[com.dean.interval-tree.tree.root]
[com.dean.interval-tree.tree.tree :as tree])
(:import [clojure.lang RT]
[com.dean.interval_tree.tree.protocol PExtensibleSet]
[com.dean.interval_tree.tree.root INodeCollection
IBalancedCollection
IOrderedCollection]))
IOrderedCollection
(getCmp [_]
cmp)
(isCompatible [_ o]
(and (instance? OrderedSet o) (= cmp (.getCmp ^OrderedSet o)) (= stitch (.getStitch ^OrderedSet o))))
(isSimilar [_ o]
(set? o))
PExtensibleSet
(intersection [this that]
(with-ordered-set this
(cond
(identical? this that) this
(.isCompatible this that) (new OrderedSet (tree/node-set-intersection root (.getRoot ^OrderedSet that))
cmp alloc stitch {})
(.isSimilar this that) (clojure.set/intersection (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(union [this that]
(with-ordered-set this
(cond
(identical? this that) this
(.isCompatible this that) (new OrderedSet (tree/node-set-union root (.getRoot ^OrderedSet that))
cmp alloc stitch {})
(.isSimilar this that) (clojure.set/union (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(difference [this that]
(with-ordered-set this
(cond
(identical? this that) (.empty this)
(.isCompatible this that) (new OrderedSet (tree/node-set-difference root (.getRoot ^OrderedSet that))
cmp alloc stitch{})
(.isSimilar this that) (clojure.set/difference (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(subset [this that]
(with-ordered-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? (.getRoot ^OrderedSet that) root) ;; Grr. reverse args of tree/subset
(.isSimilar this that) (clojure.set/subset? (into #{} this) that)
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(superset [this that]
(with-ordered-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? root (.getRoot ^OrderedSet that)) ;; Grr. reverse args of tree/subset
(.isSimilar this that) (clojure.set/subset? that (into #{} this))
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
java.util.Set
(size [_]
(tree/node-size root))
(iterator [this]
(clojure.lang.SeqIterator. (seq this)))
(containsAll [this s]
(with-ordered-set this
(cond
(identical? this s) true
(.isCompatible this s) (tree/node-subset? root (.getRoot ^OrderedSet s))
(coll? s) (every? #(.contains this %) s)
true (throw (ex-info "unsupported comparison: " {:this this :s s})))))
dco-dev/interval-tree
(ns com.dean.interval-tree.tree.interval-set
(:require [clojure.core.reducers :as r :refer [coll-fold]]
[clojure.set]
[com.dean.interval-tree.tree.interval :as interval]
[com.dean.interval-tree.tree.node :as node]
[com.dean.interval-tree.tree.order :as order]
[com.dean.interval-tree.tree.protocol :as proto]
[com.dean.interval-tree.tree.root]
[com.dean.interval-tree.tree.tree :as tree])
(:import [clojure.lang RT]
[com.dean.interval_tree.tree.protocol PExtensibleSet]
[com.dean.interval_tree.tree.root INodeCollection
IBalancedCollection
IOrderedCollection
IIntervalCollection]))
;; TODO: how should these work for interval-set?
PExtensibleSet
(intersection [this that]
(with-interval-set this
(cond
(identical? this that) this
(.isCompatible this that) (IntervalSet. (tree/node-set-intersection root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(union [this that]
(with-interval-set this
(cond
(identical? this that) this
(.isCompatible this that) (IntervalSet. (tree/node-set-union root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(difference [this that]
(with-interval-set this
(cond
(identical? this that) (.empty this)
(.isCompatible this that) (IntervalSet. (tree/node-set-difference root (.getRoot that))
cmp alloc stitch {})
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(subset [this that]
(with-interval-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? (.getRoot that) root) ;; Grr. reverse args of tree/subset
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
(superset [this that]
(with-interval-set this
(cond
(identical? this that) true
(.isCompatible this that) (tree/node-subset? root (.getRoot that)) ;; Grr. reverse args of tree/subset
true (throw (ex-info "unsupported set operands: " {:this this :that that})))))
mauricioszabo/repl-tooling
(ns repl-tooling.repl-client.parsing-test
(:require [clojure.test :refer [async testing is]]
[check.core :refer [check]]
[clojure.core.async :as async]
[devcards.core :as cards :include-macros true]
[repl-tooling.eval :as eval]
[repl-tooling.editor-helpers :as helpers]
[repl-tooling.eval-helpers :refer [eval-on-repl eval-and-parse
async-with-clj-repl]]
[repl-tooling.repl-client.clojure :as clj]))
(testing "ellisions on sets"
(let [res (eval-and-parse "(set (range 100))")
ellided (async/promise-chan)
ellide-fn (eval/get-more-fn (:result res))]
; (check (:as-text res) => #"#\{.*\.{3}\}")
(check (count (eval/without-ellision (:result res))) => 10)
(check (eval/without-ellision (:result res)) => set?)
(ellide-fn repl #(async/put! ellided %))
(check (async/<! ellided) => set?)
(check (-> ellided async/<! eval/without-ellision count) => 20)))