std.lib
$
macro
added in 3.0
($ form)template macro
(def -x- ’a)
($ (+ ~-x- 2 3)) => ’(+ a 2 3)
(let [a []] ($ (~@a))) => ()
(let a nil ($ (~@a))) => ()
->
macro
added in 3.0
(-> expr & forms)like -> but with % as placeholder
(-> 1 inc (- 10 %)) => 8
->>
macro
added in 3.0
(->> expr & forms)like ->> but with % as placeholder
(-> 1 inc (- % 10)) => -8
all-props
added in 3.0
(all-props component)lists all props in the component
(all-props (Database.)) => :interval
ancestor:list
added in 3.0
(ancestor:list cls)(ancestor:list cls output)Lists the direct ancestors of a class (ancestor:list clojure.lang.PersistentHashMap) => clojure.lang.PersistentHashMap clojure.lang.APersistentMap clojure.lang.AFn java.lang.Object
ancestor:tree
added in 3.0
(ancestor:tree cls)(ancestor:tree cls output)Lists the hierarchy of bases and interfaces of a class. (ancestor:tree Class) => java.lang.Object
apply-as
added in 3.0
(apply-as app args)allows the applicative to auto-resolve its context
(apply-as (host-applicative {:form ’+}) 1 2 3 4 5) => 15
apply-in
added in 3.0
(apply-in app rt args)runs the applicative within a context
(apply-in (host-applicative {:form ’+}) nil 1 2 3 4 5) => 15
applym
macro
added in 3.0
(applym macro & args)Allow macros to be applied to arguments just like functions
(applym const ’((+ 1 2))) => 3
(macroexpand ’(applym const ’((+ 1 2)))) => 3
arg-check
added in 3.0
(arg-check f num)(arg-check f num message)arg-count
added in 3.0
(arg-count f)array?
added in 3.0
(array? x)(array? cls x)checks if object is a primitive array
(array? (into-array [])) => true
(array? String (into-array “a” “b” “c”)) => true
assoc-new
added in 3.0
(assoc-new m k v)(assoc-new m k v & more)only assoc if the value in the original map is nil
(assoc-new {:a 1} :b 2) => {:a 1 :b 2}
(assoc-new {:a 1} :a 2 :b 2) => {:a 1 :b 2}
atom-batch-fn
added in 4.0
(atom-batch-fn prev cmds)constructs the output and next state for a batch operation
atom-delete-fn
added in 4.0
(atom-delete-fn prev paths)constructs the output and next state for a delete operation
atom-put-fn
added in 4.0
(atom-put-fn prev path m)constructs the output and next state for a put operation
atom-reduce-fn
added in 3.0
(atom-reduce-fn prev f tx entries)helper function for mutations on atom
atom-set-fn
added in 4.0
(atom-set-fn prev paths)constructs the output and next state for a set operation
atom-set-keys-fn
added in 4.0
(atom-set-keys-fn prev path m)constructs the output and next state for a set-keys operation
atom-swap-fn
added in 4.0
(atom-swap-fn prev paths)constructs the output and next state for a swap operation
atom:cursor
added in 3.0
(atom:cursor ref selector)(atom:cursor ref selector key)adds a cursor to the atom to swap on any change
atom:delete
added in 3.0
(atom:delete state path & more)deletes individual enties from path
atom:derived
added in 3.0
(atom:derived atoms f)(atom:derived atoms f key)constructs an atom derived from other atoms
atom:put-changed
added in 3.0
(atom:put-changed [old new])figure out what has changed in put operation
atom:set
added in 3.0
(atom:set state path m & more)sets the entries given a set of inputs
atom:set-changed
added in 3.0
(atom:set-changed outputs)figure out what has changed in set
atom:set-keys
added in 3.0
(atom:set-keys state path m)sets the entries given a set of inputs
atom:swap
added in 3.0
(atom:swap state path f & more)swaps entries atomically given function
atom?
added in 3.0
(atom? obj)Returns true if x is of type clojure.lang.Atom.
(atom? (atom nil)) => true
bench-ms
macro
added in 3.0
(bench-ms opts & body)measures a block in milliseconds
(bench-ms (Thread/sleep 10)) => integer?
bench-ns
macro
added in 3.0
(bench-ns opts & body)measures a block in nanoseconds
(bench-ns (Thread/sleep 1)) => integer?
bigdec?
added in 3.0
(bigdec? x)Returns true if x is of type java.math.BigDecimal.
(bigdec? 1M) => true (bigdec? 1.0) => false
bigint?
added in 3.0
(bigint? x)Returns true if x is of type clojure.lang.BigInt.
(bigint? 1N) => true (bigint? 1) => false
build-impl
macro
added in 3.0
(build-impl & body)build macro for generating functions from protocols
byte?
added in 3.0
(byte? x)Returns true if x is of type java.lang.Byte
(byte? (byte 1)) => true
call
added in 3.0
(call obj)(call obj f)(call obj f v1)(call obj f v1 v2)(call obj f v1 v2 v3)(call obj f v1 v2 v3 v4)(call obj f v1 v2 v3 v4 & vs)like invoke but reverses the function and first argument
(call 2) => 2
(call 2 + 1 2 3) => 8
charset
added in 3.0
(charset s)constructs a charset object from a string (charset “UTF-8”) => java.nio.charset.Charset
charset:default
added in 3.0
(charset:default)returns the default charset
(charset:default) => “UTF-8”
charset:list
added in 3.0
(charset:list)returns the list of available charset
(charset-list) => (“Big5” “Big5-HKSCS” … “x-windows-iso2022jp”)
class:abstract?
added in 3.0
(class:abstract? class)returns true if class is an abstract class
(class:abstract? java.util.Map) => true
(class:abstract? Class) => false
class:array-component
added in 3.0
(class:array-component cls)returns the array element within the array
(class:array-component (type (int-array 0))) => Integer/TYPE
(class:array-component (type (into-array 1 2 3))) => java.lang.Long
class:implements?
added in 3.0
(class:implements? {:keys [impls], :as protocol} type)(class:implements? protocol type method)checks whether a type has implemented a protocol
(class:implements? state/IStateGet clojure.lang.Atom) => true
class:inherits?
added in 3.0
(class:inherits? ancestor cls)checks if one class inherits from another
(class:inherits? clojure.lang.ILookup clojure.lang.APersistentMap) => true
class:interface?
added in 3.0
(class:interface? class)returns true if class is an interface
(class:interface? java.util.Map) => true
(class:interface? Class) => false
class:interfaces
added in 3.0
(class:interfaces cls)Lists all interfaces for a class
(class:interfaces clojure.lang.AFn) => #{java.lang.Runnable java.util.concurrent.Callable clojure.lang.IFn}
class:match
added in 3.0
(class:match candidates cls)finds the best matching interface or class from a list of candidates
(class:match #{Object} Long) => Object (class:match #{String} Long) => nil (class:match #{Object Number} Long) => Number
code-column
macro
added in 3.0
(code-column)gets the current code column
(code-column) => 3
code-ns
macro
added in 3.0
(code-ns)returns the current namespace the code is in
(code-ns) => ’std.lib.foundation_test
comparable?
added in 3.0
(comparable? x y)Returns true if x and y both implements java.lang.Comparable.
(comparable? 1 1) => true
component?
added in 3.0
(component? obj)checks if an instance extends IComponent
(component? (Database.)) => true
cons?
added in 3.0
(cons? x)checks if object is instance of clojure.lang.Cons
(cons? (cons 1 1 2 3)) => true
const
macro
added in 3.0
(const body)converts an expression into a constant at compile time
(const (+ 1 2)) => 3
(macroexpand ’(const (+ 1 2))) => 3
construct
added in 3.0
(construct context)(construct context ids)(construct context ids acc)builds an object from context
(construct |ctx|) => #{:c :b :a}
counter
added in 3.0
(counter)(counter n)creates a counter
(pr-str (counter)) => “#counter{-1}”
create-enum
added in 3.0
(create-enum s type)creates an enum value from a string
(create-enum “TYPE” ElementType) => ElementType/TYPE
date
added in 3.0
(date)(date t)creates a new date
(date 1000) => #inst “1970-01-01T00:00:01.000-00:00”
dec!
macro
added in 3.0
(dec! counter)(dec! counter n)decrements the counter
@(doto (counter 10) (dec! 10)) => 0
deconstruct
added in 3.0
(deconstruct context acc)(deconstruct context acc ids)deconstructs an object from context
(deconstruct |ctx| #{:c :b :a} :a) => #{}
deduped?
added in 3.0
(deduped? coll)defimpl
macro
added in 3.0
(defimpl sym bindings & body)creates a high level deftype or defrecord interface
definvoke
macro
added in 3.0
(definvoke name doc? & [attrs? & [params & body :as more]])customisable invocation forms
(definvoke -another- [:compose {:val (partial + 10) :arglists ’(& more)}])
defn.origin
macro
added in 3.0
(defn.origin name & more)creates a function with settable origin
demunge
added in 3.0
(demunge name)demunges an input to be nicer looking
(demunge ;;; (munge “+test!”) “PLUS_test_BANG”) => “+test!”
dependents-all
added in 3.0
(dependents-all context id)(dependents-all context id selected)returns graph of all dependents
dependents-direct
added in 3.0
(dependents-direct context id)(dependents-direct context id selected)returns list of direct dependents
(dependents-direct |ctx| :c) => #{:b}
dependents-ordered
added in 3.0
(dependents-ordered context id)(dependents-ordered context id selected)returns ordered depenedents
(dependents-ordered |ctx| :c) => :a :b :c
dependents-refresh
added in 3.0
(dependents-refresh context id)(dependents-refresh context id selected)refresh all dependents
deps-ordered
added in 3.0
(deps-ordered context)(deps-ordered context ids)orders dependencies
(deps-ordered |ctx|) => ’(:c :b :a)
deps-resolve
added in 3.0
(deps-resolve context ids)(deps-resolve context ids deps)resolves all dependencies
diff
added in 3.0
(diff m1 m2)(diff m1 m2 reversible)Finds the difference between two maps
diff:changed
added in 3.0
(diff:changed new old)Outputs what has changed between the two maps
(diff:changed {:a {:b {:c 3 :d 4}}} {:a {:b {:c 3}}}) => {:a {:b {:d 4}}}
diff:changes
added in 3.0
(diff:changes m1 m2)(diff:changes m1 m2 arr equal-fn)Finds changes in nested maps, does not consider new elements
diff:new
added in 3.0
(diff:new m1 m2)(diff:new m1 m2 arr)Finds new elements in nested maps, does not consider changes
difference
added in 1.0
(difference s1)(difference s1 s2)(difference s1 s2 & sets)Return a set that is the first set without elements of the remaining sets
dissoc-nested
added in 3.0
(dissoc-nested m [k & ks])dissocs recursively into a map removing empty entries
(dissoc-nested {:a {:b {:c 1}}} :a :b :c) => {}
edn
added in 3.0
(edn obj)prints then reads back the string
((juxt type (comp type edn)) (symbol “:hello”)) => clojure.lang.Symbol clojure.lang.Keyword
edn?
added in 3.0
(edn? x)checks if an entry is valid edn
(edn? 1) => true
(edn? {}) => true
(edn? (java.util.Date.)) => false
elapsed-ms
added in 3.0
(elapsed-ms ms)(elapsed-ms ms format)determines the time in ms that has elapsed
(elapsed-ms (- (time-ms) 10) true) => string?
elapsed-ns
added in 3.0
(elapsed-ns ns)(elapsed-ns ns format)determines the time in ns that has elapsed
(elapsed-ns (time-ns) true) ;; “35.42us” => string?
element-at
added in 3.0
(element-at pred coll)finds the element within an array
(element-at keyword? 1 2 :hello 4) => :hello
empty-record
added in 3.0
(empty-record v)creates an empty record from an existing one
(defrecord Database host port)
(empty-record (Database. “localhost” 8080)) => (just {:host nil :port nil})
enum-values
added in 3.0
(enum-values type)returns all values of an enum type
(->> (enum-values ElementType) (map str)) => (contains [“TYPE” “FIELD” “METHOD” “PARAMETER” “CONSTRUCTOR”] :in-any-order :gaps-ok)
enum?
added in 3.0
(enum? type)check to see if class is an enum type
(enum? java.lang.annotation.ElementType) => true
(enum? String) => false
error
macro
added in 3.0
(error message)(error message data)throws an error with message
(error “Error”) => (throws)
explode
macro
added in 3.0
(explode & body)prints the stacktrace for an exception
(explode (throw (ex-info “Error” {})))
filter-keys
added in 3.0
(filter-keys pred m)filters map based upon map keys
(filter-keys even? {0 :a 1 :b 2 :c}) => {0 :a, 2 :c}
filter-vals
added in 3.0
(filter-vals pred m)filters map based upon map values
(filter-vals even? {:a 1 :b 2 :c 3}) => {:b 2}
find-templates
added in 3.0
(find-templates m)(find-templates m path saved)finds the template with associated path
flake
added in 3.0
(flake)returns a unique, time incremental id
(flake) ;; “4Wv-T47LftnVlHhhh00JYuU15NCuNLcr” => string?
flatten-nested
added in 3.0
(flatten-nested x)flattens all elements the collection
(flatten-nested 1 2 #{3 {4 5}}) => 1 2 3 4 5
fn-body
added in 3.0
(fn-body label body)creates a function body
(fn-body :clojure ’([](+ 1 1))) => ’(clojure.core/fn [](+ 1 1))
fn-tags
added in 3.0
(fn-tags bindings)creates tags for fn
(fn-tags ^{:tag ’long} []) => “Long” nil nil
(fn-tags ^{:tag ’long} [^{:tag ’long} [] ^{:tag ’int} []]) => “Long” “Long” “Int”
fn:call-body
added in 4.1
(fn:call-body doc? attr? more)fn:create-args
added in 3.0
(fn:create-args [doc? attr? & more :as arglist])fn:def-form
added in 3.0
(fn:def-form name attrs body)(fn:def-form name doc attrs arglist body)creates a def form
fn:init-args
added in 3.0
(fn:init-args doc? attr? more)fn:lambda
macro
added in 3.0
(fn:lambda bindings & body)creates java unary/binary functions
fn:predicate
macro
added in 3.0
(fn:predicate bindings & body)creates a java predicate
(-> (fn:predicate ^long a(< a 10)) (.test 3)) => true
format-ms
added in 3.0
(format-ms time)returns ms time is human readable format
(format-ms 10000000) => “02h 46m 40s”
format-ns
added in 3.0
(format-ns time)(format-ns time digits)returns ns time in seconds
(format-ns 1000000) => “1.000ms”
fulfil
added in 3.0
(fulfil future f)(fulfil future f print)(fulfil future f print skip-success)future
macro
added in 3.0
(future)(future opts? & body)constructs a completable future
@(future (Thread/sleep 100) 1) => 1
future:call
added in 3.0
(future:call obj)(future:call obj {:keys [pool delay], :as m})can create a future from a function or :init/future
@(future:call (fn [] 1)) => 1
@(-> (future:fn (fn [] 1)) (future:call)) => 1
future:cancelled?
added in 3.0
(future:cancelled? future)checks if future has been cancelled
future:chain
added in 3.0
(future:chain future chain)(future:chain future chain marr)chains a set of functions
@(future:chain (completed 1) inc inc inc) => 4
@(future:chain (failed (ex-info “ERROR” {})) inc inc inc) => (throws)
future:complete?
added in 3.0
(future:complete? future)checks that future has successfully completed
future:dependents
added in 3.0
(future:dependents future)returns number of steps waiting on current result
future:done
macro
added in 3.0
(future:done future & body)helper macro for status functions
future:exception
added in 3.0
(future:exception future)accesses the exception in the future
future:exception?
added in 3.0
(future:exception? future)checks if future raised an exception
future:fn
added in 3.0
(future:fn f)(future:fn f {:keys [pool timeout delay default], :as m})creates a future with :init/future props
future:force
added in 3.0
(future:force future object)(future:force future type object)forces a value or exception as completed future
future:incomplete?
added in 3.0
(future:incomplete? future)check that future is incomplete
(-> (incomplete) (future:incomplete?)) => true
future:now
added in 3.0
(future:now future)(future:now future default)gets the value of a future at the current moment
future:obtrude
added in 4.0
(future:obtrude future object)(future:obtrude future type object)like force but uses obtrude and obtrudeException
future:result
added in 3.0
(future:result future)gets the result of the future
(future:result (completed 1)) => {:status :success, :data 1, :exception nil}
(future:result (failed (ex-info "" {}))) => (contains {:status :error :data nil :exception Throwable})
future:run
added in 3.0
(future:run obj)(future:run obj {:keys [pool delay timeout default], :as m})runs a function with additional settings
(future:run (fn [](Thread/sleep 100)) {:timeout 10 :default :ok :delay 100 :pool :async})
future:status
added in 3.0
(future:status future)retrieves a status of either :success, :error or waiting
future:timeout
added in 3.0
(future:timeout future interval)(future:timeout future interval default)adds a timeout to the completed future
@(-> (future:call (fn [](Thread/sleep 100))) (future:timeout 10 :ok)) => :ok
future:timeout?
added in 3.0
(future:timeout? future)checks if future errored due to timeout
future:wait
added in 3.0
(future:wait future)(future:wait future interval)waits for future to finish or
(-> (future:call (fn [](Thread/sleep 100))) (future:timeout 10 :ok) (future:wait) (future:now)) => :ok
future?
added in 3.0
(future? obj)checks if object is CompleteableFuture
(future? (future 1)) => true
get-prop
added in 3.0
(get-prop component k)gets a prop in the component
(get-prop (Database.) :interval) => 10
hash-map?
added in 3.0
(hash-map? x)Returns true if x implements clojure.lang.APersistentMap.
(hash-map? {}) => true (hash-map? []) => false
health
added in 3.0
(health component)returns the health of the component
(health (Database.)) => {:status :ok}
hierarchical-sort
added in 3.0
(hierarchical-sort idx)prunes a hierarchy of descendants into a directed graph
(hierarchical-sort {1 #{2 3 4 5 6} 2 #{3 5 6} 3 #{5 6} 4 #{} 5 #{6} 6 #{}}) => {1 #{4 2} 2 #{3} 3 #{5} 4 #{} 5 #{6} 6 #{}}
ideref?
added in 3.0
(ideref? obj)checks if
(ideref? (volatile! 0)) => true (ideref? (promise)) => true
impl:component
added in 3.0
(impl:component {:keys [name]})rewrite function compatible with std.lib.impl
impl:doto
added in 3.0
(impl:doto sym)impl:proxy
added in 3.0
(impl:proxy sym)impl:unwrap-sym
added in 3.0
(impl:unwrap-sym {:keys [name prefix suffix], :or {prefix "", suffix ""}})unwraps the protocol symbol
(impl:unwrap-sym {:name ’-val :prefix “test/” :suffix “-mock”}) => ’test/val-mock
impl:wrap-sym
added in 3.0
(impl:wrap-sym {:keys [protocol name]})wraps the protocol symbol
(impl:wrap-sym {:protocol ’protocol.test/ITest :name ’-val}) => ’protocol.test/-val
inc!
macro
added in 3.0
(inc! counter)(inc! counter n)increments the counter
@(doto (counter) (inc!) (inc! 10)) => 10
incomplete
added in 3.0
(incomplete)creates an incomplete stage (like promise)
(incomplete) => (comp not future:complete?)
index-at
added in 3.0
(index-at pred coll)finds the index of the first matching element in an array
(index-at even? 1 2 3 4) => 1
(index-at keyword? 1 2 :hello 4) => 2
info
added in 3.0
(info component)(info component level)returns info regarding the component
(info (Database.)) => {:info true}
insert-at
added in 3.0
(insert-at coll i new)(insert-at coll i new & more)insert one or more elements at the given index
(insert-at :a :b 1 :b :c) => :a :b :c :b
instant
added in 3.0
(instant)(instant val)returns a java.util.Date object
(instant) => #(instance? java.util.Date %)
(instant 0) => #inst “1970-01-01T00:00:00.000-00:00”
intern-form
added in 3.0
(intern-form ns sym)(intern-form ns sym meta)creates base form for intern-in and intern-all
(intern-form ’std.lib ’std.lib.foundation/unfold)
intern-var
added in 3.0
(intern-var ns sym var)(intern-var ns sym var ext)interns a var in sym
intersection
added in 1.0
(intersection s1)(intersection s1 s2)(intersection s1 s2 & sets)Return a set that is the intersection of the input sets
invoke
added in 3.0
(invoke f)(invoke f & args)provides a caller for the IFn
(invoke (fn [](+ 1 2 3))) => 6
invoke-as
added in 3.0
(invoke-as app & args)invokes the applicative to args
(invoke-as (host-applicative {:form ’+}) 1 2 3 4 5) => 15
invoke:arglists
added in 3.0
(invoke:arglists body)iobj?
added in 3.0
(iobj? x)checks if a component is instance of clojure.lang.IObj
(iobj? 1) => false
(iobj? {}) => true
iref?
added in 3.0
(iref? obj)Returns true if x is of type clojure.lang.IRef.
(iref? (atom 0)) => true
keep-vals
added in 3.0
(keep-vals f m)(keep-vals f pred m)filters map based upon map values
(keep-vals even? {:a 1 :b 2 :c 3}) => {:b true}
keyword
added in 3.0
(keyword obj)returns the keyword value
(keyword :hello) => :hello
(keyword “hello”) => :hello
keyword-spearify-keys
added in 4.0
(keyword-spearify-keys m)recursively transfroms all map keys to spearcase
(keyword-spearify-keys {“a_b_c” {“e_f_g” 1}}) => {:a-b-c {:e-f-g 1}}
keywordize-keys
added in 3.0
(keywordize-keys m)Recursively transforms all map keys from strings to keywords.
kill
added in 3.0
(kill component)(kill component opts)kills a systems, or if method is not defined stops it
(kill (start (Database.))) => {}
lazy-seq?
added in 3.0
(lazy-seq? x)Returns true if x implements clojure.lang.LazySeq.
(lazy-seq? (map inc 1 2 3)) => true (lazy-seq? ()) => false
local-host
added in 3.0
(local-host)returns the current host
(local-host) ;; #objectjava.net.Inet4Address 0x4523dee “chapterhouse.base.local/127.0.0.1” => java.net.Inet4Address
local-hostname
added in 3.0
(local-hostname)returns the current host name
(local-hostname) ;; “chapterhouse.base.local” => string?
local-ip
added in 3.0
(local-ip)returns the current ip
(local-ip) ;; “127.0.0.1” => string?
local-ip-lan
added in 4.0
(local-ip-lan)returns a non-loopback lan ipv4 address, preferring 192.168., then 10., then 172.16-31.*
(local-ip-lan) ;; => “192.168.1.42” => string?
local-shortname
added in 3.0
(local-shortname)returns the current host short name
(local-shortname) ;; “chapterhouse” => string?
long?
added in 3.0
(long? x)Returns true if x is of type java.lang.Long
(long? 1) => true (long? 1N) => false
macroexpand-all
added in 3.0
(macroexpand-all form)Recursively performs all possible macroexpansions in form.
map-entries
added in 3.0
(map-entries f m)manipulates a map given the function
(map-entries (fn k v (keyword (str v)) (name k)) {:a 1 :b 2 :c 3}) => {:1 “a”, :2 “b”, :3 “c”}
map-juxt
added in 3.0
(map-juxt [kf vf] arr)map-keys
added in 3.0
(map-keys f m)changes the keys of a map
(map-keys inc {0 :a 1 :b 2 :c}) => {1 :a, 2 :b, 3 :c}
map-vals
added in 3.0
(map-vals f m)changes the values of a map
(map-vals inc {:a 1 :b 2 :c 3}) => {:a 2, :b 3, :c 4}
memoize
added in 3.0
(memoize function cache var)(memoize function cache var registry status)caches the result of a function (ns-unmap ns ’+-inc-) (ns-unmap ns ‘-inc-) (def +-inc- (atom {})) (declare -inc-) (def -inc- (memoize inc +-inc- #’-inc-))
(-inc- 1) => 2 (-inc- 2) => 3
memoize:clear
added in 3.0
(memoize:clear mem)clears all results
(memoize:clear -inc-) => ’{(2) 3}
memoize:disable
added in 3.0
(memoize:disable mem)disables the usage of the cache
(memoize:disable -inc-) => :disabled
memoize:disabled?
added in 3.0
(memoize:disabled? mem)checks if the memoized function is disabled
(memoize:disabled? -inc-) => true
memoize:enable
added in 3.0
(memoize:enable mem)enables the usage of the cache
(memoize:enable -inc-) => :enabled
memoize:enabled?
added in 3.0
(memoize:enabled? mem)checks if the memoized function is disabled
(memoize:enabled? -inc-) => true
memoize:info
added in 3.0
(memoize:info mem)formats the memoize object
(def +-plus- (atom {})) (declare -plus-) (def -plus- (memoize + +-plus- #’-plus-)) (memoize:info -plus-) => (contains {:status :enabled, :registered false, :items number?}) ;; {:fn +, :cache #atom {(1 1) 2}}
memoize:invoke
added in 3.0
(memoize:invoke mem & args)invokes the function with arguments
(memoize:invoke -plus- 1 2 3) => 6
memoize:remove
added in 3.0
(memoize:remove mem & args)removes a cached result
(memoize:remove -inc- 1) => 2
memoize:status
added in 3.0
(memoize:status mem)returns the status of the object
(memoize:status -inc-) => :enabled
merge-nested
added in 3.0
(merge-nested & maps)Merges nested values from left to right.
(merge-nested {:a {:b {:c 3}}} {:a {:b 3}}) => {:a {:b 3}}
(merge-nested {:a {:b {:c 1 :d 2}}} {:a {:b {:c 3}}}) => {:a {:b {:c 3 :d 2}}}
merge-nested-new
added in 3.0
(merge-nested-new & maps)Merges nested values from left to right, provided the merged value does not exist
(merge-nested-new {:a {:b 2}} {:a {:c 2}}) => {:a {:b 2 :c 2}}
(merge-nested-new {:b {:c :old}} {:b {:c :new}}) => {:b {:c :old}}
multi:add
added in 3.0
(multi:add multi dispatch-val method)adds an entry to the multimethod
(multi:add hello :c (clojure.core/fn m(assoc m :c 3))) => hello
multi:clone
added in 3.0
(multi:clone source name)creates a multimethod from an existing one
multi:get
added in 3.0
(multi:get multi dispatch)returns all entries in the multimethod
(multi:get hello :a) => fn?
multi:list
added in 3.0
(multi:list multi)returns all entries in the multimethod
(keys (multi:list world)) => (contains :a :b :in-any-order)
multi:remove
added in 3.0
(multi:remove multi val)removes an entry
(multi:remove world :b) => ifn?
multi?
added in 3.0
(multi? obj)returns true if obj is a multimethod
(multi? print-method) => true
(multi? println) => false
native?
added in 3.0
(native?)checks if execution is in graal
(native?) ;;false => boolean?
on:all
added in 3.0
(on:all futures)(on:all futures f)(on:all futures f {:keys [timeout pool default delay], :as m})calls a function when all futures are complete
on:any
added in 3.0
(on:any futures f)(on:any futures f {:keys [timeout pool default delay], :as m})calls a function when any future is completed
on:cancel
added in 3.0
(on:cancel future f)(on:cancel future f m)processes a function on cancel
on:complete
added in 3.0
(on:complete future f)(on:complete future f {:keys [timeout pool default delay], :as m})process both the value and exception
on:exception
added in 3.0
(on:exception future f)(on:exception future f {:keys [timeout pool default delay], :as m})process a function on exception
on:success
added in 3.0
(on:success future f)(on:success future f {:keys [timeout pool default delay], :as m})processes another step given successful operation
on:timeout
added in 3.0
(on:timeout future f)(on:timeout future f {:keys [timeout pool default delay], :as m})processes a function on timeout
parse-double
added in 3.0
(parse-double s)parses a double from string
(parse-double “100”) => 100.0
(parse-double “100.123”) => 100.123
parse-ms
added in 3.0
(parse-ms s)parses the string representation of time in ms
(parse-ms “1s”) => 1000
(parse-ms “0.5h”) => 1800000
parse-ns
added in 3.0
(parse-ns s)parses the string repesentation of time in ns
(parse-ns “2ns”) => 2
(parse-ns “0.3s”) => 300000000
pl-add-lines
added in 3.0
(pl-add-lines body)(pl-add-lines body [start end])(pl-add-lines body [start end] [pad-h pad-v])helper function for pl
port:check-available
added in 4.0
(port:check-available port)check that port is available
(port:check-available 51311) => anything
port:get-available
added in 4.0
(port:get-available ports)get first available port from a range
(port:get-available 51312 51313) => number?
postwalk
added in 3.0
(postwalk f form)Performs a depth-first, post-order traversal of form
postwalk-replace
added in 3.0
(postwalk-replace smap form)Recursively transforms form by replacing keys in smap with their values.
prewalk-replace
added in 3.0
(prewalk-replace smap form)Recursively transforms form by replacing keys in smap with their values.
primitive
added in 3.0
(primitive v to)Converts primitive values across their different representations. The choices are: :raw - The string in the jdk (i.e. Z for Boolean, C for Character) :symbol - The symbol that std.object.query uses for matching (i.e. boolean, char, int) :string - The string that std.object.query uses for matching :class - The primitive class representation of the primitive :container - The containing class representation for the primitive type
primitive:array?
added in 3.0
(primitive:array? cls)checks if class is a primitive array
(primitive:array? (type (int-array 0))) => true
(primitive:array? (type (into-array 1 2 3))) => false
protocol-tmpl
added in 3.0
(protocol-tmpl {:keys [prefix protocol instance resolve default]})constructs a template function
protocol:impls
added in 3.0
(protocol:impls protocol)returns types that implement the protocol
(protocol:impls state/IStateSet) => (any (contains clojure.lang.Agent clojure.lang.Ref clojure.lang.IAtom clojure.lang.Volatile clojure.lang.IPending clojure.lang.Var :in-any-order :gaps-ok) #{})
(protocol:impls state/IStateGet) => (any (contains clojure.lang.IDeref clojure.lang.IPending :in-any-order :gaps-ok) #{})
protocol:interface
added in 3.0
(protocol:interface protocol)returns the java interface for a given protocol
(protocol:interface state/IStateGet) => std.protocol.state.IStateGet
protocol:methods
added in 3.0
(protocol:methods protocol)returns the methods provided by the protocol
(protocol:methods state/IStateSet) => ’-clone-state -empty-state -set-state -update-state
protocol:remove
added in 3.0
(protocol:remove protocol atype)protocol:signatures
added in 3.0
(protocol:signatures protocol)returns the method signatures provided by the protocol
(protocol:signatures state/IStateSet) => ’{-update-state {:arglists (obj f args opts) :doc nil} -set-state {:arglists (obj v opts) :doc nil} -empty-state {:arglists (obj opts) :doc nil} -clone-state {:arglists (obj opts) :doc nil}}
protocol?
added in 3.0
(protocol? obj)checks whether an object is a protocol
(protocol? state/IStateGet) => true
qualified-keys
added in 3.0
(qualified-keys m)(qualified-keys m ns)takes only the namespaced keys of a map
(qualified-keys {:a 1 :ns/b 1}) => #:ns{:b 1}
(qualified-keys {:a 1 :ns.1/b 1 :ns.2/c 1} :ns.1) => #:ns.1{:b 1}
qualify-keys
added in 3.0
(qualify-keys m ns)lifts all unqualified keys
(qualify-keys {:a 1} :ns.1) => #:ns.1{:a 1}
(qualify-keys {:a 1 :ns.2/c 1} :ns.1) => {:ns.1/a 1, :ns.2/c 1}
queue
added in 3.0
(queue)(queue x)(queue x & xs)returns a clojure.lang.PersistentQueue object.
(pop a) => 2 3 4
regexp?
added in 3.0
(regexp? x)Returns true if x implements clojure.lang.IPersistentMap.
(regexp? #“\d+”) => true
registry-get
added in 3.0
(registry-get ctx)gets the context type
(registry-get :null) => (contains-in {:context :null, :rt {:default {:key :default, :resource :hara/context.rt.null, :config {}}}})
registry-install
added in 3.0
(registry-install ctx)(registry-install ctx config)installs a new context type
(registry-install :play.test)
registry-rt
added in 3.0
(registry-rt ctx)(registry-rt ctx key)gets the runtime type information
registry-rt-add
added in 3.0
(registry-rt-add ctx {:keys [key], :as config})installs a context runtime type
registry-rt-list
added in 3.0
(registry-rt-list)(registry-rt-list ctx)return all runtime types
(registry-rt-list)
registry-rt-remove
added in 3.0
(registry-rt-remove ctx key)uninstalls a context runtime type
registry-scratch
added in 4.0
(registry-scratch ctx)gets the scratch runtime for a registered context
registry-uninstall
added in 3.0
(registry-uninstall ctx)uninstalls a new context type
(registry-uninstall :play.test)
reload-entry
added in 3.0
(reload-entry context id)unloads and reloads itself and all dependents
remote?
added in 3.0
(remote? component)returns whether the component connects remotely
(remote? (Database.)) => false
remove-at
added in 3.0
(remove-at coll i)(remove-at coll i n)removes element at the specified index
(remove-at :a :b :c :d 2) => :a :b :d
rename-keys
added in 4.0
(rename-keys m trs)rename keys in map
(rename-keys {:a 1} {:a :b}) => {:b 1}
res
(res type)(res type config)(res type input config)(res type variant input config)(res mode type variant key config)res:active
added in 3.0
(res:active)(res:active type)(res:active type variant)gets all active resources
(res:active)
res:exists?
(res:exists? type)(res:exists? type input)(res:exists? type variant input)(res:exists? mode type variant key)res:mode
added in 3.0
(res:mode type)(res:mode type variant)gets the default mode of a resource
(res:mode :hara/concurrent.atom.executor) => :global
(res:mode :hara/concurrent.atom.executor :std.concurrent.print) => :global
res:path
(res:path type)(res:path type input)(res:path type variant input)(res:path mode type variant key)res:restart
(res:restart type)(res:restart type input)(res:restart type variant input)(res:restart mode type variant key)res:set
(res:set type instance)(res:set type input instance)(res:set type variant input instance)(res:set mode type variant key instance)res:spec-get
added in 3.0
(res:spec-get type)retrieves a resource spec
(res:spec-get :hara/concurrent.atom.executor) => map?
res:start
(res:start type)(res:start type config)(res:start type input config)(res:start type variant input config)(res:start mode type variant key config)res:stop
(res:stop type)(res:stop type input)(res:stop type variant input)(res:stop mode type variant key)res:variant-add
added in 3.0
(res:variant-add type {:keys [id alias], :as spec})adds a spec variant
res:variant-get
added in 3.0
(res:variant-get type)(res:variant-get type id)gets a new variant
res:variant-list
added in 3.0
(res:variant-list)(res:variant-list type)retrieves a list of variants to the spec
(res:variant-list :hara/concurrent.atom.executor) => coll?
reset!
added in 3.0
(reset! counter n)resets a counter to the given value
(reset! (counter 10) 5) => 5
reshape
added in 3.0
(reshape m rels)return-chain
added in 3.0
(return-chain out f)chains a function if a future or resolves if not
(return-chain 1 inc) => 2
@(return-chain (f/future 1) inc) => 2
return-resolve
added in 3.0
(return-resolve res)resolves encased futures
(return-resolve (f/future (f/future 1))) => 1
seqify
added in 3.0
(seqify x)set!
macro
added in 3.0
(set! sym val)sets a var without changing current meta
(std.lib.foundation/set! -lost- 1)
set-origin
added in 3.0
(set-origin ns-origin & [ns-source])sets the origin of a namespace
set-prop
added in 3.0
(set-prop component k value)sets a prop in the component
(set-prop (Database.) :interval 3) => (throws)
sh
added in 3.0
(sh m)(sh s & args)sh-kill-tree
added in 4.0
(sh-kill-tree process)calls destroyForcibly on the process and all descendants.
Uses java.lang.ProcessHandle when available (Java 9+) so that child processes spawned by the root process are also terminated. Falls back to sh-kill on Java 8 or if ProcessHandle is unavailable.
sh-read
added in 4.0
(sh-read process)reads value from stdout
(sh-read (sh “ls” {:wait true :output false})) => string?
sha1
added in 3.0
(sha1 body)function for sha1 hash
(sha1 “123”) => “40bd001563085fc35165329ea1ff5c5ecbdbbeef”
short?
added in 3.0
(short? x)Returns true if x is of type java.lang.Short
(short? (short 1)) => true
signal:with-temp
macro
added in 3.0
(signal:with-temp [checker handler] & body)uses a temporary signal manager for testing
socket
added in 3.0
(socket port)(socket host port)creates a new socket
(h/suppress (with-open s ^java.net.Socket (socket 51311) s))
socket:local-address
added in 3.0
(socket:local-address socket)getst the local socket address
space
added in 3.0
(space)(space namespace)gets the space in the current namespace
(space)
space-resolve
added in 3.0
(space-resolve obj)resolves a space given various inputs
(space-resolve ns)
space:context-set
(space:context-set ctx key options)(space:context-set sp ctx key options)space:rt-current
added in 4.0
(space:rt-current ctx)(space:rt-current namespace ctx)gets the current rt in the space
start
added in 3.0
(start component)(start component opts)starts a component/array/system
(start (Database.)) => {:status “started”}
start
added in 3.0
(start component)(start component opts)starts a component/array/system
(start (Database.)) => {:status “started”}
started?
added in 3.0
(started? component)checks if a component has been started
(started? 1) => true
(started? (start {})) => true
(started? (Database.)) => true
started?
added in 3.0
(started? component)checks if a component has been started
(started? 1) => true
(started? (start {})) => true
(started? (Database.)) => true
stop
added in 3.0
(stop component)(stop component opts)stops a component/array/system
(stop (start (Database.))) => {}
stop
added in 3.0
(stop component)(stop component opts)stops a component/array/system
(stop (start (Database.))) => {}
stopped?
added in 3.0
(stopped? component)checks if a component has been stopped
(stopped? 1) => false
(stopped? {}) => false
(stopped? (start {})) => false
(stopped? (Database.)) => false
stopped?
added in 3.0
(stopped? component)checks if a component has been stopped
(stopped? 1) => false
(stopped? {}) => false
(stopped? (start {})) => false
(stopped? (Database.)) => false
string
added in 3.0
(string obj)creates a string from a byte array
(string (.getBytes “Hello”)) => “Hello”
string-snakify-keys
added in 4.0
(string-snakify-keys m)recursively transforms keyword to string keys
(string-snakify-keys {:a-b-c {:e-f-g 1}}) => {“a_b_c” {“e_f_g” 1}}
stringify-keys
added in 3.0
(stringify-keys m)Recursively transforms all map keys from keywords to strings.
strn
added in 3.0
(strn obj)(strn obj & more)returns the strn value
(strn :hello) => “hello”
(strn “hello”) => “hello”
subset?
added in 1.2
(subset? set1 set2)Is set1 a subset of set2?
superset?
added in 1.2
(superset? set1 set2)Is set1 a superset of set2?
suppress
macro
added in 3.0
(suppress body)(suppress body catch-val)Suppresses any errors thrown in the body.
(suppress (throw (ex-info “Error” {}))) => nil
(suppress (throw (ex-info “Error” {})) :error) => :error
(suppress (throw (ex-info “Error” {})) (fn ^Throwable e (.getMessage e))) => “Error”
swap-return!
added in 3.0
(swap-return! atm f)(swap-return! atm f state?)returns output and new state of atom
sys:resource
added in 3.0
(sys:resource n)(sys:resource n loader)finds a resource on class path
sys:wget-bulk
added in 4.0
(sys:wget-bulk root-url root-path files & [args])download files using call to wget
system-ns
added in 3.0
(system-ns)returns the system nano time
(system-ns) ;; 8158606456270 => number?
template-bulk
macro
added in 4.0
(template-bulk [tmpl-fn & [tmpl-meta]] entries)template-entries but for heavy usage
template-ensure
added in 4.0
(template-ensure syms vars)ensures that the templated entries are the same as the input
template-entries
macro
added in 3.0
(template-entries [tmpl-fn & [tmpl-meta]] & entries)uses a template function to produce entries
template-vars
macro
added in 3.0
(template-vars [tmpl-fn & [tmpl-meta]] & syms)adds a function to current given var and arguments
template:locals
macro
added in 3.0
(template:locals)gets local variable symbol names and values
(let x 1 y 2 (template:locals)) => ’{x 1, y 2}
then
macro
added in 3.0
(then future bindings & body)shortcut for :on/success and :on/complete
thread-form
added in 3.0
(thread-form forms transform-fn)thread?
added in 3.0
(thread? obj)Returns true is x is a thread
(thread? (Thread/currentThread)) => true
throwable-string
added in 3.0
(throwable-string t)creates a string from a throwable
(throwable-string (ex-info “ERROR” {})) => string?
throwable?
added in 3.0
(throwable? obj)checks that object is a Throwable
(throwable? (ex-info “hello” {})) => true
time-ms
added in 3.0
(time-ms)returns current time in milli seconds
(time-ms) ;; 1593922917603 => number?
time-ns
added in 3.0
(time-ns)returns current time in nano seconds
(time-ns) ;; 1593922814991449423 => number?
time-us
added in 3.0
(time-us)returns current time in micro seconds
(time-us) ;; 1593922882412533 => number?
tmux-with-args
added in 4.0
(tmux-with-args cmd {:keys [root env]})creates tmux args
(tmux-with-args “tmux” {:root “.” :env {:hello “world”}}) => [“tmux” “-c” “.” “-e” “HELLO=world”]
tmux:has-window?
added in 4.0
(tmux:has-window? session key)checks if window exists in a session
tmux:new-session
added in 4.0
(tmux:new-session session & [opts])creates a new tmux session
tmux:new-window
added in 4.0
(tmux:new-window session key & [opts])opens a new window in the session
tmux:run-command
added in 4.0
(tmux:run-command session key cmd)runs a command in a window
to-enum
added in 3.0
(to-enum s type)gets an enum value given a symbol
(to-enum “TYPE” ElementType) => ElementType/TYPE
(to-enum :field ElementType) => ElementType/FIELD
topological-sort
added in 3.0
(topological-sort g)(topological-sort g l s)sorts a directed graph into its dependency order
(topological-sort {:a #{:b :c}, :b #{:d :e}, :c #{:e :f}, :d #{}, :e #{:f}, :f nil}) => :f :d :e :b :c :a
(topological-sort {:a #{:b}, :b #{:a}}) => (throws)
topological-sort-order-by-deps
added in 4.0
(topological-sort-order-by-deps g sorted-list)Refines a topologically sorted list by sorting nodes at each dependency level by their dependency count. Takes the dependency graph and a pre-sorted list. A secondary sort is done on the node key to ensure a stable ordering.
trace
macro
added in 3.0
(trace)(trace val)prints out the item and a program trace
(trace “Error”) => Throwable
trace-print-ns
added in 4.0
(trace-print-ns)(trace-print-ns ns)adds a print trace to entire namespace
transform-fn
added in 3.0
(transform-fn schema [from to])creates a transformation function ((transform-fn {:keystore {:hash “{{hash}}” :salt “{{salt}}” :email “{{email}}”}
:db {:login {:user {:hash "{{hash}}"
:salt "{{salt}}"}
:value "{{email}}"}}}
[:keystore :db]) ^:hidden
{:type :email, :hash “1234” :salt “ABCD” :email “[email protected]”}) => {:type :email :login {:user {:hash “1234”, :salt “ABCD”}, :value “[email protected]”}}
transpose
added in 3.0
(transpose m)sets the vals and keys and vice-versa
(transpose {:a 1 :b 2 :c 3}) => {1 :a, 2 :b, 3 :c}
tree-flatten
added in 3.0
(tree-flatten m)(tree-flatten m sep)(tree-flatten m sep path)flattens the entire map tree
(->> (tree-flatten {“a” {“b” {“c” 3 “d” 4} “e” {“f” 5 “g” 6}} “h” {“i” {}}}) (map-keys h/strn)) => {“a/b/c” 3, “a/b/d” 4, “a/e/f” 5, “a/e/g” 6}
tree-nestify
added in 3.0
(tree-nestify m)(tree-nestify m sep)(tree-nestify m sep f)nests keys in the map
(tree-nestify {:a/b 2 :a/c 3}) => {:a {:b 2 :c 3}}
(tree-nestify {:a/b {:e/f 1} :a/c {:g/h 1}}) => {:a {:b {:e/f 1} :c {:g/h 1}}}
tree-nestify:all
added in 3.0
(tree-nestify:all m)(tree-nestify:all m sep)nests keys in the map and all submaps
(tree-nestify:all {:a/b 2 :a/c 3}) => {:a {:b 2 :c 3}}
(tree-nestify:all {:a/b {:e/f 1} :a/c {:g/h 1}}) => {:a {:b {:e {:f 1}} :c {:g {:h 1}}}}
unbound?
added in 3.0
(unbound? obj)checks if a variable is unbound
(declare -lost-)
(unbound? -lost-) = true
unfold
added in 3.0
(unfold f coll)unfolds using a generated function
(unfold (fn i :as seed (if i (if-not (neg? i) [(* i 2) (dec i)]))) 10) => 20 18 16 14 12 10 8 6 4 2 0
union
added in 1.0
(union)(union s1)(union s1 s2)(union s1 s2 & sets)Return a set that is the union of the input sets
unload-entry
added in 3.0
(unload-entry context id)unloads itself as well as all dependents for a given id
unqualified-keys
added in 3.0
(unqualified-keys m)takes only the namespaced keys of a map
(unqualified-keys {:a 1 :ns/b 1}) => {:a 1}
unqualify-keys
added in 3.0
(unqualify-keys m)(unqualify-keys m ns)unqualifies keys in the map
(unqualify-keys {:a 1 :ns.1/b 1 :ns.2/c 1}) => {:a 1, :b 1, :c 1}
(unqualify-keys {:a 1 :ns.1/b 1 :ns.2/c 1} :ns.1) => {:a 1, :b 1, :ns.2/c 1}
unseqify
added in 3.0
(unseqify x)uri
added in 3.0
(uri path)returns a java.net.UrI object
(uri “http://www.google.com”) => java.net.URI
url
added in 3.0
(url path)retruns a java.net.URL object
(url “http://www.google.com”) => java.net.URL
url?
added in 3.0
(url? x)Returns true if x is of type java.net.URL.
(url? (java.net.URL. “file:/Users/chris/Development”)) => true
uuid
added in 3.0
(uuid)(uuid id)(uuid msb lsb)returns a java.util.UUID object
(uuid) => #(instance? java.util.UUID %)
(uuid “00000000-0000-0000-0000-000000000000”) => #uuid “00000000-0000-0000-0000-000000000000”
var-sym
added in 3.0
(var-sym var)converts a var to a symbol
(var-sym #’var-sym) => ’std.lib.foundation/var-sym
varg-count
added in 3.0
(varg-count f)vargs?
added in 3.0
(vargs? f)wait-for-port
added in 3.0
(wait-for-port host port)(wait-for-port host port {:keys [timeout pause], :as opts})waits for a port to be ready
(wait-for-port “localhost” 51313 {:timeout 1000}) => (throws)
walk:contains
added in 4.0
(walk:contains pred form)recursively walks form to check for containment
with
macro
added in 3.0
(with [var expr & more] & body)do tests with an active component
(with db (Database.) (started? db)) => true
with-ex
macro
added in 4.0
(with-ex & body)gets the exception data in a form
(with-ex (throw (ex-info “Error” {:hello “1”}))) => {:hello “1”}
with-out-str
macro
added in 3.0
(with-out-str & body)gets the local string
(print/with-out-str (print/print “hello”)) => “hello”
with-thrown
macro
added in 4.0
(with-thrown & body)gets the exception data in a form
(ex-data (with-thrown (throw (ex-info “Error” {:hello “1”})))) => {:hello “1”}
with:template-meta
macro
added in 3.0
(with:template-meta meta & body)binds the template meta (for testing purposes)
wrapped
added in 4.0
(wrapped val)(wrapped val show)(wrapped val show type)(wrapped val show type display)object to display shell result
xor
macro
added in 3.0
(xor)(xor a)(xor a b)performs xor comparison
(xor true false) => true