Public Vars

Back

disj (clj)

(source)

function

(disj set) (disj set key) (disj set key & ks)
disj[oin]. Returns a new set of the same (hashed/sorted) type, that does not contain key(s).

Examples

clojure/core.typed
(ns clojure.core.typed.test.filter-ops
  (:require 
    ; this loads the type system, must go first
    [clojure.core.typed.test.test-utils :refer :all]
    [clojure.core.typed :as t]
    [clojure.core.typed.checker.filter-ops :refer [-and -filter -not-filter -or]]
    [clojure.core.typed.checker.filter-rep :refer [-top make-AndFilter make-OrFilter -bot]]
    [clojure.core.typed.checker.type-rep :refer []]
    [clojure.core.typed.checker.jvm.parse-unparse :refer [parse-type]]
    [clojure.core.typed.checker.jvm.subtype :refer [subtype-type-filter?]]
            [clojure.test :refer :all]))

  ;normalise to conjunctions of disjunctions
  (is (= (-or (-and (-filter (parse-type nil) 0)
                    (-filter (parse-type nil) 1))
              (-and (-filter (parse-type nil) 2)
                    (-filter (parse-type nil) 3)))
         (apply make-AndFilter
                (for [l [0 1]
                      r [2 3]]
                  (make-OrFilter (-filter (parse-type nil) l)
                                 (-filter (parse-type nil) r)))))))
seancorfield/next-jdbc
(ns next.jdbc-test
  "Basic tests for the primary API of `next.jdbc`."
  (:require [clojure.core.reducers :as r]
            [clojure.string :as str]
            [clojure.test :refer [deftest is testing use-fixtures]]
            [next.jdbc :as jdbc]
            [next.jdbc.connection :as c]
            [next.jdbc.test-fixtures
             :refer [with-test-db db ds column
                     default-options stored-proc?
                     derby? hsqldb? jtds? mssql? mysql? postgres? sqlite?]]
            [next.jdbc.prepare :as prep]
            [next.jdbc.result-set :as rs]
            [next.jdbc.specs :as specs]
            [next.jdbc.types :as types])
  (:import (com.zaxxer.hikari HikariDataSource)
           (com.mchange.v2.c3p0 ComboPooledDataSource PooledDataSource)
           (java.sql ResultSet ResultSetMetaData)))

(deftest connection-tests
  (testing "datasource via jdbcUrl"
    (when-not (postgres?)
      (let [[url etc] (#'c/spec->url+etc (db))
            ds (jdbc/get-datasource (assoc etc :jdbcUrl url))]
        (cond (derby?) (is (= {:create true} etc))
              (mssql?) (is (= (cond-> #{:user :password}
                                (not (jtds?))
                                (conj :encrypt :trustServerCertificate))
                              (set (keys etc))))
              (mysql?) (is (= #{:user :password :useSSL :allowMultiQueries}
                              (disj (set (keys etc)) :disableMariaDbDriver)))
              :else    (is (= {} etc)))
        (is (instance? javax.sql.DataSource ds))
        (is (str/index-of (pr-str ds) (str "jdbc:"
                                           (cond (jtds?)
                                                 "jtds:sqlserver"
                                                 (mssql?)
                                                 "sqlserver"
                                                 :else
                                                 (:dbtype (db))))))
        ;; checks get-datasource on a DataSource is identity
        (is (identical? ds (jdbc/get-datasource ds)))
        (with-open [con (jdbc/get-connection ds {})]
          (is (instance? java.sql.Connection con)))))))
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))))

#?(:cljs (do
(t/ann-protocol cljs.core/Fn)
(t/ann-protocol cljs.core/IFn)
(t/ann-protocol cljs.core/ICloneable
                -clone [cljs.core/ICloneable :-> t/Any])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IIterable
                ;; TODO
                -iterator [(cljs.core/IIterable x) :-> t/Any #_Object])
(t/ann-protocol cljs.core/ICounted
                -count [cljs.core/ICounted :-> t/Num])
(t/ann-protocol cljs.core/IEmptyableCollection
                ;; :/ TFn param on protocol?
                -empty [cljs.core/IEmptyableCollection :-> t/Any])
(t/ann-protocol cljs.core/ICollection
                -conj [cljs.core/ICollection t/Any :-> cljs.core/ICollection])
(t/ann-protocol [[x :variance :covariant]] cljs.core/IIndexed
                -nth (t/All [y]
                            [(cljs.core/IIndexed x) t/JSnumber (t/? y) :-> (t/U x y)]))
(t/ann-protocol cljs.core/ASeq)
(t/ann-protocol [[x :variance :covariant
                  ;;FIXME causes mystery error
                  ;:< t/AnyNilableNonEmptySeq
                  ]]
                cljs.core/ISeqable)
(t/ann-protocol [[x :variance :covariant]] cljs.core/ISeq
                -first [(cljs.core/ISeq x) :-> (t/Nilable x)]
                -rest [(cljs.core/ISeq x) :-> (cljs.core/ISeq x)])
;cljs.core/INext [[x :variance :covariant]]
(t/ann-protocol [[v :variance :covariant]] cljs.core/ILookup)
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]]
                cljs.core/IAssociative
                -contains-key [(cljs.core/IAssociative k v) t/Any :-> t/Bool]
                -assoc (t/All [k1 v1] [(cljs.core/IAssociative k v) k1 v1 :->
                                       (cljs.core/IAssociative (t/U k k1) (t/U v v1))]))
(t/ann-protocol cljs.core/IMap
                -dissoc [cljs.core/IMap t/Any :-> cljs.core/IMap])
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]]
                cljs.core/IMapEntry
                -key [(cljs.core/IMapEntry k v) :-> k]
                -val [(cljs.core/IMapEntry k v) :-> v])
(t/ann-protocol cljs.core/ISet
                -disjoin (t/All [s] [s t/Any :-> s]))
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IStack
                -peek [(cljs.core/IStack x) :-> (t/U nil x)]
                -pop [(cljs.core/IStack x) :-> (cljs.core/IStack x)])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IVector
                -assoc-n (t/All [x1] [(cljs.core/IVector x) t/Num x1
                                      :-> (cljs.core/IVector (t/U x x1))]))
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IDeref
                -deref [(cljs.core/IDeref x) :-> x])
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IDerefWithTimeout
                -deref-with-timeout [(cljs.core/IDerefWithTimeout x) :-> x])
(t/ann-protocol cljs.core/IMeta
                -meta [cljs.core/IMeta :-> (t/Nilable (t/Map t/Any t/Any))])
(t/ann-protocol cljs.core/IWithMeta
                -with-meta [cljs.core/IWithMeta (t/Nilable (t/Map t/Any t/Any)) :-> cljs.core/IWithMeta])
;TODO
;cljs.core/IReduce [[]]
(t/ann-protocol cljs.core/IKVReduce ;;TODO
                -kv-reduce [cljs.core/IKVReduce [t/Any t/Any t/Any :-> t/Any] :-> t/Any])
(t/ann-protocol cljs.core/IList)
(t/ann-protocol cljs.core/IEquiv
                -equiv [cljs.core/IEquiv t/Any :-> t/Bool])
(t/ann-protocol cljs.core/IHash
                -hash [cljs.core/IHash :-> t/Num])
(t/ann-protocol cljs.core/ISequential)
(t/ann-protocol cljs.core/IRecord)
(t/ann-protocol [[x :variance :covariant]]
                cljs.core/IReversible
                -rseq [(cljs.core/IReversible x) :-> (t/NilableNonEmptySeq x)])
(t/ann-protocol [[k :variance :covariant]
                 [v :variance :covariant]] cljs.core/IFind
                -find [(cljs.core/IFind k v) t/Any :-> (t/Nilable (cljs.core/IMapEntry k v))]
                )
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/ISorted
                -sorted-seq [(cljs.core/ISorted x) t/Bool :-> (t/Nilable (t/ASeq x))]
                ;; second arg => comparable?
                -sorted-seq-from [(cljs.core/ISorted x) t/Any t/Bool :-> (t/Nilable (t/ASeq x))]
                -entry-key [(cljs.core/ISorted x) t/Any :-> t/Any]
                -comparator [(cljs.core/ISorted x) :-> [x x :-> t/Num]])
(t/ann-protocol cljs.core/IPending)
;cljs.core/IWriter [[]]
;cljs.core/IPrintWithWriter [[]]
;    ;TODO
;;cljs.core/IWatchable [[]]
;    ;cljs.core/IEditableCollection [[]]
;    ;cljs.core/ITransientCollection [[]]
;    ;cljs.core/ITransientAssociative [[]]
;    ;cljs.core/ITransientMap [[]]
;    ;cljs.core/ITransientVector [[]]
;    ;cljs.core/ITransientSet [[]]
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/IComparable)
;    ;cljs.core/IChunk [[]]
;    ;cljs.core/IChunkedSeq [[]]
;    ;cljs.core/IChunkedNext [[]]
(t/ann-protocol cljs.core/INamed
                -named [cljs.core/INamed :-> t/Str]
                -namespace [cljs.core/INamed :-> (t/Nilable t/Str)])
(t/ann-protocol [[x :variance :invariant]]
                cljs.core/IVolatile
                -vreset! (t/All [x] [(cljs.core/IVolatile x) x :-> x]))

cc/disj (t/All [x] (t/IFn [(t/SortedSet x) t/Any :* :-> (t/SortedSet x)]
                          [(t/Set x) t/Any :* :-> (t/Set x)]))
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]))

  clojure.lang.IPersistentSet
  (equiv [this o]
    (with-interval-set this
      (cond
        (identical? this o) true
        (.isCompatible this o) (and (= (.count this) (.count o))
                                    (zero? (tree/node-set-compare root (.getRoot o))))
        true (throw (ex-info "unsupported comparison: " {:this this :o o})))))
  (count [_]
    (tree/node-size root))
  (empty [_]
    (IntervalSet. (node/leaf) cmp alloc stitch {}))
  (contains [this k]
    (with-interval-set this
      (some? (seq (tree/node-find-intervals this (interval/ordered-pair k))))))
  (disjoin [this k]
    (with-interval-set this
      (IntervalSet. (tree/node-remove root (interval/ordered-pair k)) cmp alloc stitch _meta)))
  (cons [this k]
    (with-interval-set this
      (IntervalSet. (tree/node-add root (interval/ordered-pair k)) cmp alloc stitch _meta)))
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]))

  clojure.lang.IPersistentSet
  (equiv [this o]
    (with-ordered-set this
      (cond
        (identical? this o) true
        (not= (tree/node-size root) (.count ^clojure.lang.Counted o)) false
        (.isCompatible this o) (zero? (tree/node-set-compare root (.getRoot ^OrderedSet o)))
        (.isSimilar    this o) (.equiv ^clojure.lang.IPersistentSet (into (empty o) this) o)
        true     (throw (ex-info "unsupported comparison: " {:this this :o o})))))
  (count [_]
    (tree/node-size root))
  (empty [_]
    (new OrderedSet (node/leaf) cmp alloc stitch {}))
  (contains [this k]
    (with-ordered-set this
      (if (tree/node-find root k) true false)))
  (disjoin [this k]
    (with-ordered-set this
      (new OrderedSet (tree/node-remove root k) cmp alloc stitch _meta)))
  (cons [this k]
    (with-ordered-set this
      (new OrderedSet (tree/node-add root k) cmp alloc stitch _meta)))