diff --git a/core/procs.go b/core/procs.go index 67633b88c..2b2979bd6 100644 --- a/core/procs.go +++ b/core/procs.go @@ -47,7 +47,7 @@ const ( PRINT_IF_NOT_NIL ) -const VERSION = "v0.10.2" +const VERSION = "v0.11.0" var internalLibs map[string][]byte diff --git a/docs/joker.core.html b/docs/joker.core.html index 5d63dfd5a..3764e5bd9 100644 --- a/docs/joker.core.html +++ b/docs/joker.core.html @@ -219,6 +219,9 @@
bound in a repl to the most recent value printed
- source + sourcebound in a repl to the second most recent value printed
- source + sourcebound in a repl to the third most recent value printed
- source + sourcebound in a repl to the most recent exception caught by the repl
- source + sourceWhen set to true, output will be flushed whenever a newline is printed.
Defaults to true.
(alias alias namespace-sym)
Add an alias in the current namespace to another
namespace. Arguments are two symbols: the alias to be used, and
the symbolic name of the target namespace. Use :as in the ns macro in preference
to calling this directly.
(all-ns)
Returns a sequence of all namespaces.
- source + source(alter-meta! ref f & args)
Atomically sets the metadata for a namespace/var/atom to be:
(apply f its-current-meta args)
f must be free of side-effects
(array-map & keyvals)
Constructs an array-map. If any keys are equal, they are handled as
if by repeated uses of assoc.
(as-> expr name & forms)
Binds name to expr, evaluates the first form in the lexical context
of that binding, then binds name to that result, repeating for each
successive form, returning the result of the last form.
(assert x message)
Evaluates expr and throws an exception if it does not evaluate to
logical true.
(assoc-in m ks v)
Associates a value in a nested associative structure, where ks is a
sequence of keys and v is the new value and returns a new nested structure.
If any levels do not exist, hash-maps will be created.
(associative? coll)
Returns true if coll implements Associative
- source + source(atom x & options)
Creates and returns an Atom with an initial value of x and zero or
more options (in any order):
:meta metadata-map
If metadata-map is supplied, it will become the metadata on the
atom.
(bigfloat x)
Coerce to BigFloat
- source + source(bigfloat? n)
Returns true if n is a BigFloat
- source + source(bigint x)
Coerce to BigInt
- source + source(binding bindings & body)
binding => var-symbol init-expr
Creates new bindings for the (already-existing) vars, with the
supplied initial values, executes the exprs in an implicit do, then
re-establishes the bindings that existed before. The new bindings
are made in parallel (unlike let); all init-exprs are evaluated
before the vars are bound to their new values.
(boolean x)
Coerce to boolean
- source + source(bound? & vars)
Returns true if all of the vars provided as arguments have any bound value.
Implies that deref'ing the provided vars will succeed. Returns true if no vars are provided.
(bounded-count n coll)
If coll is counted? returns its count, else will count at most the first n
elements of coll using its seq
(callable? x)
Returns true if x implements Callable. Note that many data structures
(e.g. sets and maps) implement Callable.
(case expr & clauses)
Takes an expression, and a set of clauses.
Each clause can take the form of either:
test-expr result-expr
(test-expr ... test-expr) result-expr
If the expression is equal to a value of
test-expr, the corresponding result-expr is returned. A single
default expression can follow the clauses, and its value will be
returned if no clause matches. If no default expression is provided
and no clause matches, an exception is thrown.
(char x)
Coerce to char
- source + sourceAlways returns false because chunked sequences are not supported
source++(class x)
Returns the Type of x.
+ source +(coll? x)
Returns true if x implements Collection
- source + source(comment & body)
Ignores body, yields nil
- source + source(comp f1 f2 f3 & fs)
Takes a set of functions and returns a fn that is the composition
of those fns. The returned fn takes a variable number of args,
applies the rightmost of fns to the args, the next
fn (right-to-left) to the result, etc.
(cond-> expr & clauses)
Takes an expression and a set of test/form pairs. Threads expr (via ->)
through each form for which the corresponding test
expression is true. Note that, unlike cond branching, cond-> threading does
not short circuit after the first true test expression.
(cond->> expr & clauses)
Takes an expression and a set of test/form pairs. Threads expr (via ->>)
through each form for which the corresponding test expression
is true. Note that, unlike cond branching, cond->> threading does not short circuit
after the first true test expression.
(condp pred expr & clauses)
Takes a binary predicate, an expression, and a set of clauses.
Each clause can take the form of either:
test-expr result-expr
test-expr :>> result-fn
Note :>> is an ordinary keyword.
For each clause, (pred test-expr expr) is evaluated. If it returns
logical true, the clause is a match. If a binary clause matches, the
result-expr is returned, if a ternary clause matches, its result-fn,
which must be a unary function, is called with the result of the
predicate as its argument, the result of that call being the return
value of condp. A single default expression can follow the clauses,
and its value will be returned if no clause matches. If no default
expression is provided and no clause matches, an
exception is thrown.
(counted? coll)
Returns true if coll implements count in constant time
- source + source(create-ns sym)
Create a new namespace named by the symbol if one doesn't already
exist, returns it or the already-existing namespace of the same
name.
(cycle coll)
Returns a lazy (infinite!) sequence of repetitions of the items in coll.
- source + source(declare & names)
defs the supplied var names with no bindings, useful for making forward declarations.
- source + source(dedupe coll)
Returns a lazy sequence removing consecutive duplicates in coll.
- source + sourceDefault map of data reader functions provided by Joker. May be
overridden by binding *data-readers*.
Like defn, but the resulting function name is declared as a
macro and will be used as a macro by the compiler when it is
called.
++(defmethod multifn dispatch-val & fn-tail)
Creates and installs a new method of multimethod associated with dispatch-value.
+ source +++(defmulti name docstring? attr-map? dispatch-fn & options)
Creates a new multimethod with the associated dispatch function.
The docstring and attr-map are optional.
Options are key-value pairs and may be one of:
:default
The default dispatch value, defaults to :default
:hierarchy (UNSUPPORTED)
The value used for hierarchical dispatch (e.g. ::square is-a ::shape)
Hierarchies are type-like relationships that do not depend upon type
inheritance. By default Clojure's multimethods dispatch off of a
global hierarchy map. However, a hierarchy relationship can be
created with the derive function used to augment the root ancestor
created with make-hierarchy.
Multimethods expect the value of the hierarchy option to be supplied as
a reference type e.g. a var (i.e. via the Var-quote dispatch macro #'
or the var special form).
(defn- name & decls)
same as defn, yielding non-public def
- source + source(defonce name expr)
defs name to have the value of the expr if the named var is not bound,
else expr is unevaluated
(denominator r)
Returns the denominator part of a Ratio.
- source + source(deref ref)
Also reader macro: @var/@atom/@delay. When applied to a var or atom,
returns its current state. When applied to a delay, forces
it if not already forced.
(distinct coll)
Returns a lazy sequence of the elements of coll with duplicates removed.
- source + source(distinct? x y & more)
Returns true if no two of the arguments are =
- source + source(doall n coll)
When lazy sequences are produced via functions that have side
effects, any effects other than those needed to produce the first
element in the seq do not occur until the seq is consumed. doall can
be used to force any effects. Walks through the successive nexts of
the seq, retains the head and returns it, thus causing the entire
seq to reside in memory at one time.
(dorun n coll)
When lazy sequences are produced via functions that have side
effects, any effects other than those needed to produce the first
element in the seq do not occur until the seq is consumed. dorun can
be used to force any effects. Walks through the successive nexts of
the seq, does not retain the head and returns nil.
(doseq seq-exprs & body)
Repeatedly executes body (presumably for side-effects) with
bindings and filtering as provided by "for". Does not retain
the head of the sequence. Returns nil.
(dotimes bindings & body)
bindings => name n
Repeatedly executes body (presumably for side-effects) with name
bound to integers from 0 through n-1.
(doto x & forms)
Evaluates x then calls all of the methods and functions with the
value of x supplied at the front of the given arguments. The forms
are evaluated in order. Returns x.
(double x)
Coerce to double
- source + source(drop n coll)
Returns a lazy sequence of all but the first n items in coll.
- source + source(drop-last n s)
Return a lazy sequence of all but the last n (default 1) items in coll
- source + source(drop-while pred coll)
Returns a lazy sequence of the items in coll starting from the first
item for which (pred item) returns logical false.
(empty coll)
Returns an empty collection of the same category as coll, or nil
- source + source(empty? coll)
Returns true if coll has no items - same as (not (seq coll)).
Please use the idiom (seq x) rather than (not (empty? x))
(eval form)
Evaluates the form data structure (not text!) and returns the result.
- source + source(every-pred p1 p2 p3 & ps)
Takes a set of predicates and returns a function f that returns true if all of its
composing predicates return a logical true value against all of its arguments, else it returns
false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical false result against the original predicates.
(every? pred coll)
Returns true if (pred x) is logical true for every x in coll, else
false.
(ex-cause ex)
Returns the cause of ex if ex is an ExInfo.
Otherwise returns nil.
(ex-data ex)
Returns exception data (a map) if ex is an ExInfo.
Otherwise returns nil.
(ex-message ex)
Returns the message attached to ex if ex is an ExInfo.
Otherwise returns nil.
(filter pred coll)
Returns a lazy sequence of the items in coll for which
(pred item) returns true. pred must be free of side-effects.
(filterv pred coll)
Returns a vector of the items in coll for which
(pred item) returns true. pred must be free of side-effects.
(find-ns sym)
Returns the namespace named by the symbol or nil if it doesn't exist.
- source + source(find-var sym)
Returns the global var named by the namespace-qualified symbol, or
nil if no var with that name.
(flatten x)
Takes any nested combination of sequential things (lists, vectors,
etc.) and returns their contents as a single, flat sequence.
(flatten nil) returns an empty sequence.
(float? n)
Returns true if n is a floating point number
- source + source(flush)
Flushes the output stream that is the current value of
*out*
(fn name? ([params*] exprs*) +)
params => positional-params* , or positional-params* & next-param
positional-param => binding-form
next-param => binding-form
name => symbol
Defines a function
(fn? x)
Returns true if x is Fn, i.e. is an object created via fn.
- source + source(fnil f x y z)
Takes a function f, and returns a function that calls f, replacing
a nil first argument to f with the supplied value x. Higher arity
versions can replace arguments in the second and third
positions (y, z). Note that the function f can take any number of
arguments, not just the one(s) being nil-patched.
(for seq-exprs body-expr)
List comprehension. Takes a vector of one or more
binding-form/collection-expr pairs, each followed by zero or more
modifiers, and yields a lazy sequence of evaluations of expr.
Collections are iterated in a nested fashion, rightmost fastest,
and nested coll-exprs can refer to bindings created in prior
binding-forms. Supported modifiers are: :let [binding-form expr ...],
:while test, :when test.
(take 100 (for [x (range 100000000) y (range 1000000) :while (< y x)] [x y]))
(format fmt & args)
Formats a string using fmt.Sprintf
- source + source(frequencies coll)
Returns a map from distinct items in coll to the number of times
they appear.
(get-in m ks not-found)
Returns the value in a nested associative structure,
where ks is a sequence of keys. Returns nil if the key
is not present, or the not-found value if supplied.
++(get-method multifn dispatch-val)
Given a multimethod and a dispatch value, returns the dispatch fn
that would apply to that value, or nil if none apply and no default
(group-by f coll)
Returns a map of the elements of coll keyed by the result of
f on each element. The value at each key will be a vector of the
corresponding elements, in the order they appeared in coll.
(hash x)
Returns the hash code of its argument.
- source + source(in-ns name)
Sets *ns* to the namespace named by the symbol, creating it if needed.
- source + source(indexed? coll)
Return true if coll implements Indexed, indicating efficient lookup by index
- source + source(interleave c1 c2 & colls)
Returns a lazy seq of the first item in each coll, then the second etc.
- source + source(intern ns name val)
Finds or creates a var named by the symbol name in the namespace
ns (which can be a symbol or a namespace), setting its root binding
to val if supplied. The namespace must exist. The var will adopt any
metadata from the name symbol. Returns the var.
(interpose sep coll)
Returns a lazy seq of the elements of coll separated by sep.
Returns a stateful transducer when no collection is provided.
(into to from)
Returns a new coll consisting of to-coll with all of the items of
from-coll conjoined.
(iterate f x)
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects
- source + source(joker-version)
Returns joker version as a printable string.
- source + source(juxt f g h & fs)
Takes a set of functions and returns a fn that is the juxtaposition
of those fns. The returned fn takes a variable number of args, and
returns a vector containing the result of applying each fn to the
args (left-to-right).
((juxt a b c) x) => [(a x) (b x) (c x)]
(keep f coll)
Returns a lazy sequence of the non-nil results of (f item). Note,
this means false return values will be included. f must be free of
side-effects.
(keep-indexed f coll)
Returns a lazy sequence of the non-nil results of (f index item). Note,
this means false return values will be included. f must be free of
side-effects.
(lazy-cat & colls)
Expands to code which yields a lazy sequence of the concatenation
of the supplied colls. Each coll expr is not evaluated until it is
needed.
(lazy-cat xs ys zs) === (concat (lazy-seq xs) (lazy-seq ys) (lazy-seq zs))
(let [bindings*] exprs*)
binding => binding-form init-expr
Evaluates the exprs in a lexical context in which the symbols in
the binding-forms are bound to their respective init-exprs or parts
therein.
(list? x)
Returns true if x is a List
- source + source(load & libs)
Loads code from libs.
- source + source(load-file f)
Loads code from file f
- source + source(load-string s)
Sequentially read and evaluate the set of forms contained in the
string
(loaded-libs)
Returns an UNSORTED set of symbols naming the currently loaded libs
- source + source(loop [bindings*] exprs*)
Evaluates the exprs in a lexical context in which the symbols in
the binding-forms are bound to their respective init-exprs or parts
therein. Acts as a recur target.
(macroexpand form)
Repeatedly calls macroexpand-1 on form until it no longer
represents a macro form, then returns it. Note neither
macroexpand-1 nor macroexpand expand macros in subforms.
(macroexpand-1 form)
If form represents a macro form, returns its expansion, else returns form.
- source + source(map f c1 c2 c3 & colls)
Returns a lazy sequence consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments.
(map-indexed f coll)
Returns a lazy sequence consisting of the result of applying f to 0
and the first item of coll, followed by applying f to 1 and the second
item in coll, etc, until coll is exhausted. Thus function f should
accept 2 arguments, index and item.
(mapcat f & colls)
Returns the result of applying concat to the result of applying map
to f and colls. Thus function f should return a collection.
(mapv f c1 c2 c3 & colls)
Returns a vector consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments.
(max-key k x y & more)
Returns the x for which (k x), a number, is greatest.
- source + source(memoize f)
Returns a memoized version of a referentially transparent function. The
memoized version of the function keeps a cache of the mapping from arguments
to results and, when calls with the same arguments are repeated often, has
higher performance at the expense of higher memory use.
(merge & maps)
Returns a map that consists of the rest of the maps conj-ed onto
the first. If a key occurs in more than one map, the mapping from
the latter (left-to-right) will be the mapping in the result.
(merge-with f & maps)
Returns a map that consists of the rest of the maps conj-ed onto
the first. If a key occurs in more than one map, the mapping(s)
from the latter (left-to-right) will be combined with the mapping in
the result by calling (f val-in-result val-in-latter).
Returns the metadata of obj, returns nil if there is no metadata.
source++(methods multifn)
Given a multimethod, returns a map of dispatch values -> dispatch fns
+ source +(min-key k x y & more)
Returns the x for which (k x), a number, is least.
- source + source(mod num div)
Modulus of num and div. Truncates toward negative infinity.
- source + source(newline)
Writes a platform-specific newline to *out*
- source + source(not-any? pred coll)
Returns false if (pred x) is logical true for any x in coll,
else true.
(not-empty coll)
If coll is empty, returns nil, else coll
- source + source(not-every? pred coll)
Returns false if (pred x) is logical true for every x in
coll, else true.
(ns name docstring? attr-map? references*)
Sets *ns* to the namespace named by name (unevaluated), creating it
if needed. references can be zero or more of:
(:require ...) (:use ...) (:load ...)
with the syntax of require/use/load
respectively, except the arguments are unevaluated and need not be
quoted. Use of ns is preferred to
individual calls to in-ns/require/use:
(ns foo.bar
(:require [my.lib1 :as lib1])
(:use [my.lib2]))
(ns-aliases ns)
Returns a map of the aliases for the namespace.
- source + source(ns-interns ns)
Returns a map of the intern mappings for the namespace.
- source + source(ns-map ns)
Returns a map of all the mappings for the namespace.
- source + source(ns-name ns)
Returns the name of the namespace, a symbol.
- source + source(ns-publics ns)
Returns a map of the public intern mappings for the namespace.
- source + source(ns-refers ns)
Returns a map of the refer mappings for the namespace.
- source + source(ns-resolve ns env sym)
Returns the var or type to which a symbol will be resolved in the
namespace (unless found in the environment), else nil. Note that
if the symbol is fully qualified, the var/Type to which it resolves
need not be present in the namespace.
(ns-unalias ns sym)
Removes the alias for the symbol from the namespace.
- source + source(ns-unmap ns sym)
Removes the mappings for the symbol from the namespace.
- source + source(nthnext coll n)
Returns the nth next of coll, (seq coll) when n is 0.
- source + source(nthrest coll n)
Returns the nth rest of coll, coll when n is 0.
- source + source(num x)
Coerce to Number
- source + source(number? x)
Returns true if x is a Number
- source + source(numerator r)
Returns the numerator part of a Ratio.
- source + source(partial f arg1 arg2 arg3 & more)
Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
(partition n step pad coll)
Returns a lazy sequence of lists of n items each, at offsets step
apart. If step is not supplied, defaults to n, i.e. the partitions
do not overlap. If a pad collection is supplied, use its elements as
necessary to complete last partition upto n items. In case there are
not enough padding elements, return a partition with less than n items.
(partition-all n step coll)
Returns a lazy sequence of lists like partition, but may include
partitions with fewer than n items at the end.
(partition-by f coll)
Applies f to each value in coll, splitting it each time f returns a
new value. Returns a lazy seq of partitions.
(pprint x)
Pretty prints x to the output stream that is the current value of *out*.
- source + source(pr & args)
Prints the object(s) to the output stream that is the current value
of *out*. Prints the object(s), separated by spaces if there is
more than one. By default, pr and prn print in a way that objects
can be read by the reader
(pr-err & xs)
pr to *err*
- source + source(pr-str & xs)
pr to a string, returning it
- source + source +++(prefer-method multifn dispatch-val-x dispatch-val-y)
Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y
when there is a conflict
++(prefers multifn)
Given a multimethod, returns a map of preferred value -> set of other values
+ source(print & more)
Prints the object(s) to the output stream that is the current value
of *out*. print and println produce output for human consumption.
(print-err & xs)
print to *err*
- source + source(print-str & xs)
print to a string, returning it
- source + source(printf fmt & args)
Prints formatted output, as per format
- source + source(println & more)
Same as print followed by (newline)
- source + source(println-err & xs)
println to *err*
- source + source(println-str & xs)
println to a string, returning it
- source + source(prn & more)
Same as pr followed by (newline). Observes *flush-on-newline*
- source + source(prn-err & xs)
prn to *err*
- source + source(prn-str & xs)
prn to a string, returning it
- source + source(rand n)
Returns a random floating point number between 0 (inclusive) and
n (default 1) (exclusive).
(rand-int n)
Returns a random integer between 0 (inclusive) and n (exclusive).
- source + source(rand-nth coll)
Return a random element of the (sequential) collection. Will have
the same performance characteristics as nth for the given
collection.
(random-sample prob coll)
Returns items from coll with random probability of prob (0.0 -
1.0).
(range start end step)
Returns a lazy seq of nums from start (inclusive) to end
(exclusive), by step, where start defaults to 0, step to 1, and end to
infinity. When step is equal to 0, returns an infinite sequence of
start. When start is equal to end, returns empty list.
(ratio? n)
Returns true if n is a Ratio
- source + source(rational? n)
Returns true if n is a rational number
- source + source(re-find re s)
Returns the leftmost regex match, if any, of string to pattern.
- source + source(re-matches re s)
Returns the match, if any, of string to pattern.
- source + source(re-pattern s)
Returns an instance of Regex
- source + source(re-seq re s)
Returns a sequence of successive matches of pattern in string
- source + source(read reader)
Reads the next object from reader (defaults to *in*)
- source + source(read-line)
Reads the next line from *in*. Returns nil if an error (such as EOF) is detected.
- source + source(read-string s)
Reads one object from the string s.
- source + source(realized? x)
Returns true if a value has been produced for a delay or lazy sequence.
- source + source(reduce-kv f init coll)
Reduces an associative collection. f should be a function of 3
arguments. Returns the result of applying f to init, the first key
and the first value in coll, then applying f to that result and the
2nd key and value, etc. If coll contains no entries, returns init
and f is not called. Note that reduce-kv is supported on vectors,
where the keys will be the ordinals.
(reductions f init coll)
Returns a lazy seq of the intermediate values of the reduction (as
per reduce) of coll by f, starting with init.
(refer ns-sym & filters)
refers to all public vars of ns, subject to filters.
filters can include at most one each of:
:exclude list-of-symbols
:only list-of-symbols
:rename map-of-fromsymbol-tosymbol
For each public interned var in the namespace named by the symbol,
adds a mapping from the name of the var to the var to the current
namespace. Throws an exception if name is already mapped to
something else in the current namespace. Filters can be used to
select a subset, via inclusion or exclusion, or to provide a mapping
to a symbol different from the var's name, in order to prevent
clashes. Use :use in the ns macro in preference to calling this directly.
++(refer-clojure & filters)
Same as (refer 'joker.core
(remove pred coll)
Returns a lazy sequence of the items in coll for which
(pred item) returns false. pred must be free of side-effects.
++(remove-all-methods multifn)
Removes all of the methods of multimethod.
+ source +++(remove-method multifn dispatch-val)
Removes the method of multimethod associated with dispatch-value.
+ source(remove-ns sym)
Removes the namespace named by the symbol. Use with caution.
Cannot be used to remove the clojure namespace.
(repeat n x)
Returns a lazy (infinite!, or length n if supplied) sequence of xs.
- source + source(repeatedly n f)
Takes a function of no args, presumably with side effects, and
returns an infinite (or length n if supplied) lazy sequence of calls
to it
(replace smap coll)
Given a map of replacement pairs and a vector/collection, returns a
vector/seq with any elements = a key in smap replaced with the
corresponding val in smap.
(require & args)
Loads libs, skipping any that are already loaded. Each argument is
either a libspec that identifies a lib, a prefix list that identifies
multiple libs whose names share a common prefix, or a flag that modifies
how all the identified libs are loaded. Use :require in the ns macro
in preference to calling this directly.
Libs
A 'lib' is a named set of resources in classpath whose contents define a
library of Clojure code. Lib names are symbols and each lib is associated
with a Clojure namespace and a Java package that share its name. A lib's
name also locates its root directory within classpath using Java's
package name to classpath-relative path mapping. All resources in a lib
should be contained in the directory structure under its root directory.
All definitions a lib makes should be in its associated namespace.
'require loads a lib by loading its root resource. The root resource path
is derived from the lib name in the following manner:
Consider a lib named by the symbol 'x.y.z; it has the root directory
resource should contain code to create the lib's namespace (usually by using
the ns macro) and load any additional lib resources.
Libspecs
A libspec is a lib name or a vector containing a lib name followed by
options expressed as sequential keywords and arguments.
Recognized options:
:as takes a symbol as its argument and makes that symbol an alias to the
lib's namespace in the current namespace.
:refer takes a list of symbols to refer from the namespace or the :all
keyword to bring in all public vars.
Prefix Lists
It's common for Clojure code to depend on several libs whose names have
the same prefix. When specifying libs, prefix lists can be used to reduce
repetition. A prefix list contains the shared prefix followed by libspecs
with the shared prefix removed from the lib names. After removing the
prefix, the names that remain must not contain any periods.
Flags
A flag is a keyword.
Recognized flags: :reload, :reload-all, :verbose
:reload forces loading of all the identified libs even if they are
already loaded
:reload-all implies :reload and also forces loading of all libs that the
identified libs directly or indirectly load via require or use
:verbose triggers printing information about each load, alias, and refer
Example:
The following would load the libraries clojure.zip and clojure.set
abbreviated as 's'.
(require '(clojure zip [set :as s]))
(requiring-resolve sym)
Resolves namespace-qualified sym per 'resolve'. If initial resolve
fails, attempts to require sym's namespace and retries.
(reset! atom newval)
Sets the value of atom to newval without regard for the
current value. Returns newval.
(reset-meta! ref metadata-map)
Atomically resets the metadata for a namespace/var/atom
- source + source(reset-vals! atom newval)
Sets the value of atom to newval. Returns [old new], the value of the
atom before and after the reset.
(resolve env sym)
Same as (ns-resolve *ns* sym) or (ns-resolve *ns* env sym)
- source + source(reversible? coll)
Returns true if coll implements Reversible
- source + source(run! proc coll)
Runs the supplied procedure (via reduce), for purposes of side
effects, on successive items in the collection. Returns nil.
(seqable? x)
Return true if the seq function is supported for x
- source + source(sequence coll)
Coerces coll to a (possibly empty) sequence, if it is not already
one. Will not force a lazy seq. (sequence nil) yields ()
(sequential? coll)
Returns true if coll implements Sequential
- source + source(set coll)
Returns a set of the distinct elements of coll.
- source + source(set? x)
Returns true if x implements Set
- source + source(shuffle coll)
Return a random permutation of coll
- source + source(slurp f)
Opens file f and reads all its contents, returning a string.
- source + source(some pred coll)
Returns the first logical true value of (pred x) for any x in coll,
else nil. One common idiom is to use a set as pred, for example
this will return :fred if :fred is in the sequence, otherwise nil:
(some #{:fred} coll)
(some-> expr & forms)
When expr is not nil, threads it into the first form (via ->),
and when that result is not nil, through the next etc.
(some->> expr & forms)
When expr is not nil, threads it into the first form (via ->>),
and when that result is not nil, through the next etc.
(some-fn p1 p2 p3 & ps)
Takes a set of predicates and returns a function f that returns the first logical true value
returned by one of its composing predicates against any of its arguments, else it returns
logical false. Note that f is short-circuiting in that it will stop execution on the first
argument that triggers a logical true result against the original predicates.
(sort comp coll)
Returns a sorted sequence of the items in coll. If no comparator is
supplied, uses compare.
(sort-by keyfn comp coll)
Returns a sorted sequence of the items in coll, where the sort
order is determined by comparing (keyfn item). If no comparator is
supplied, uses compare.
(special-symbol? s)
Returns true if s names a special form
- source + source(spit f content)
Opposite of slurp. Opens file f, writes content, then
closes f.
(split-at n coll)
Returns a vector of [(take n coll) (drop n coll)]
- source + source(split-with pred coll)
Returns a vector of [(take-while pred coll) (drop-while pred coll)]
- source + source(subs s start end)
Returns the substring of s beginning at start inclusive, and ending
at end (defaults to length of string), exclusive.
(subvec v start end)
Returns a persistent vector of the items in vector from
start (inclusive) to end (exclusive). If end is not supplied,
defaults to (count vector). This operation is O(1) and very fast, as
the resulting vector shares structure with the original and no
trimming is done.
(swap! atom f & args)
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args).
Returns the value that was swapped in.
(swap-vals! atom f & args)
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args). Note that f may be called
multiple times, and thus should be free of side effects.
Returns [old new], the value of the atom before and after the swap.
(take n coll)
Returns a lazy sequence of the first n items in coll, or all items if
there are fewer than n.
(take-last n coll)
Returns a seq of the last n items in coll. Depending on the type
of coll may be no better than linear time. For vectors, see also subvec.
(take-nth n coll)
Returns a lazy seq of every nth item in coll.
- source + source(take-while pred coll)
Returns a lazy sequence of successive items from coll while
(pred item) returns true. pred must be free of side-effects.
(test v)
test [v] finds fn at key :test in var metadata and calls it,
presuming failure will throw exception
(the-ns x)
If passed a namespace, returns it. Else, when passed a symbol,
returns the namespace named by it, throwing an exception if not
found.
(time expr)
Evaluates expr and prints the time it took. Returns the value of expr.
- source + source(trampoline f & args)
trampoline can be used to convert algorithms requiring mutual
recursion without stack consumption. Calls f with supplied args, if
any. If f returns a fn, calls that fn with no arguments, and
continues to repeat, until the return value is not a fn, then
returns that non-fn value. Note that if you want to return a fn as a
final value, you must wrap it in some data structure and unpack it
after trampoline returns.
(tree-seq branch? children root)
Returns a lazy sequence of the nodes in a tree, via a depth-first walk.
branch? must be a fn of one arg that returns true if passed a node
that can have children (but may not). children must be a fn of one
arg that returns a sequence of the children. Will only be called on
nodes for which branch? returns true. Root is the root node of the
tree.
(type x)
Returns the :type metadata of x, or its Type if none
- source + source(update m k f x y z & more)
'Updates' a value in an associative structure, where k is a
key and f is a function that will take the old value
and any supplied args and return the new value, and returns a new
structure. If the key does not exist, nil is passed as the old value.
(update-in m ks f & args)
'Updates' a value in a nested associative structure, where ks is a
sequence of keys and f is a function that will take the old value
and any supplied args and return the new value, and returns a new
nested structure. If any levels do not exist, hash-maps will be
created.
(use & args)
Like 'require, but also refers to each lib's namespace using
joker.core/refer. Use :use in the ns macro in preference to calling
this directly.
'use accepts additional options in libspecs: :exclude, :only, :rename.
The arguments and semantics for :exclude, :only, and :rename are the same
as those documented for joker.core/refer.
(var-get x)
Gets the value in the var object
- source + source(var-set x val)
Sets the value in the var object to val.
- source + source(var? v)
Returns true if v is of type Var
- source + source(when-first bindings & body)
bindings => x xs
Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once
(while test & body)
Repeatedly executes body while test expression is true. Presumes
some side-effect will cause test to become false/nil. Returns nil
(with-bindings binding-map & body)
Takes a map of Var/value pairs. Sets the vars to the corresponding values.
Then executes body. Resets the vars back to the original
values after body was evaluated. Returns the value of body.
(with-bindings* binding-map f & args)
Takes a map of Var/value pairs. Sets the vars to the corresponding values.
Then calls f with the supplied arguments. Resets the vars back to the original
values after f returned. Returns whatever f returns.
(with-in-str s & body)
Evaluates body in a context in which *in* is bound to a fresh
Buffer initialized with the string s.
(with-out-str & body)
Evaluates exprs in a context in which *out* is bound to a fresh
Buffer. Returns the string created by any nested printing
calls.
(with-redefs bindings & body)
The same as binding
- source + source(with-redefs-fn binding-map f & args)
The same as with-bindings*
- source + source(xml-seq root)
A tree seq on the xml elements as per xml/parse
- source + source(zipmap keys vals)
Returns a map with the keys mapped to the corresponding vals.
- source + sourceReturns a sequence of the command line arguments, starting with the program name (normally, joker).
+ +++(chdir dirname)
Chdir changes the current working directory to the named directory. If there is an error, an exception will be thrown. Returns nil.
+