Back
conj (clj)
(source)variable
(conj)
(conj coll)
(conj coll x)
(conj coll x & xs)
conj[oin]. Returns a new collection with the xs
'added'. (conj nil item) returns (item).
(conj coll) returns coll. (conj) returns [].
The 'addition' may happen at different 'places' depending
on the concrete type.
Examples
clj-kondo/clj-kondo
(ns expanded-by-clj-kondo
(:require [clojure.core :as cc]))
(cond-> [] true (conj 1))
noprompt/meander
(ns multimethods
(:refer-clojure :exclude [defmethod defmulti])
(:require
#?(:clj [clojure.core :as clj] :cljs [cljs.core :as cljs])
[meander.epsilon :as m]))
(defmacro defmethod
[mf [& lhr] & body]
(swap! cache_ assoc-in [mf lhr] body)
(let [ptrns (get @cache_ mf)]
`(-set-fn ~(with-meta mf {:tag `MultiMeanderFn})
(fn [& ~'argsv]
(m/match ~'argsv
~@(loop [[[l r] & more] ptrns xs []]
(if l
(recur more (conj xs l (cons `do r)))
xs)))))))
hraberg/deuce
(ns deuce.emacs.marker
(:use [deuce.emacs-lisp :only (defun defvar) :as el])
(:require [clojure.core :as c]
[deuce.emacs.alloc :as alloc]
[deuce.emacs.buffer :as buffer]
[deuce.emacs.data :as data])
(:import [deuce.emacs.data Buffer BufferText Marker])
(:refer-clojure :exclude []))
(defun set-marker (marker position &optional buffer)
"Position MARKER before character number POSITION in BUFFER.
BUFFER defaults to the current buffer.
If POSITION is nil, makes marker point nowhere.
Then it no longer slows down editing in any buffer.
Returns MARKER."
(let [^Buffer buffer (el/check-type 'bufferp (or buffer (buffer/current-buffer)))
^Marker marker marker]
(when-let [^Buffer old-buffer @(.buffer marker)]
(swap! (.markers ^BufferText (.text old-buffer)) #(seq (remove #{marker} %))))
(reset! (.buffer marker) buffer)
(reset! (.charpos marker) position)
(swap! (.markers ^BufferText (.text buffer)) conj marker)
marker))
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]))
(t/defalias
^{:doc "Values that can be conj'ed to a t/Map, adding keys of type k
and vals of type v."}
t/MapConjable
(t/TFn [[k :variance :covariant]
[v :variance :covariant]]
(t/U (t/MapEntry k v)
'[k v]
(t/Seqable (t/MapEntry k v)))))
cc/conj
; (t/All [e
; [Arg :< (t/TFn [[x :variance :covariant]] t/Any)]
; [Res :< (t/TFn [[x :variance :covariant]]
; (t/Coll t/Any))]]
; (t/IFn [(clojure.lang.IPersistentCollection e Arg Res) (Arg e) (Arg e) :* :-> (Res e)]
; [nil e e :* :-> (clojure.lang.PersistentList e)]))
(t/All [x y] (t/IFn [(t/Vec x) (t/+ x) :-> (t/Vec x)]
#?(:clj [(APersistentMap x y) (t/+ (t/MapConjable x y)) :-> (APersistentMap x y)])
[(t/Map x y) (t/+ (t/MapConjable x y)) :-> (t/Map x y)]
[(t/Set x) (t/+ x) :-> (t/Set x)]
[(t/ASeq x) (t/+ x) :-> (t/ASeq x)]
#?(:clj [nil (t/+ x) :-> (clojure.lang.PersistentList x)])
;unsound. t/Coll would need an extra param to specify Conjable elements.
[(t/Nilable (t/Coll t/Any)) (t/+ t/Any) :-> (t/Coll t/Any)]))
; IPersistentCollection [[x :variance :covariant]
; :conj-fn [conj-fn :kind (t/TFn [[x :variance :covariant]] (IPersistentCollection x))]
; :empty-fn [empty-fn :kind (t/TFn [] (IPersistentCollection t/Nothing :count (ExactCount 0)))]]
; cc/conj
; (t/All [x conj-fn]
; [(IPersistentCollection x :conj-fn conj-fn) x :-> (conj-fn x)]
; [nil x :-> (PersistentList x)]
; [(t/U nil (IPersistentCollection x :conj-fn conj-fn)) x :-> (t/U nil (conj-fn x))])
bsless/more.async
(ns more.async.dataflow.node
(:require
[clojure.spec.alpha :as s]
[clojure.core.async :as a]
[more.async :as ma]
[clojure.data]))
(defmethod -compile ::batch
[{{from ::from
to ::to
size ::size
timeout ::timeout
rf ::rf
init ::init-fn
finally ::finally-fn
async? ::async?
:or {rf conj init (constantly []) finally identity}}
::batch} env]
(let [from (env from)
to (env to)]
(if async?
(ma/batch! from to size timeout rf init finally)
(a/thread (ma/batch!! from to size timeout rf init finally)))))