From c2fe8f8068f6874a42fd624924351809bd06766c Mon Sep 17 00:00:00 2001
From: Roman Bataev bound in a repl to the most recent value printed bound in a repl to the second most recent value printed bound in a repl to the third most recent value printed bound in a repl to the most recent exception caught by the repl When set to true, output will be flushed whenever a newline is printed. Default map of data reader functions provided by Joker. May be Takes a value from ch.*1
v1.0
*2
v1.0
*3
v1.0
*e
v1.0
*flush-on-newline*
Defaults to true.default-data-readers
overridden by binding *data-readers*.<!
Returns nil if ch is closed and nothing is available on ch.
Blocks if nothing is available on ch and ch is not closed.>!
Throws an exception if val is nil.
Blocks if ch is full (no buffer space is available).
Returns true unless ch is already closed.
(all-ns)
^Seq (all-ns)
Returns a sequence of all namespaces.
- source + source show typesConstructs an array-map. If any keys are equal, they are handled as
if by repeated uses of assoc.
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.
Evaluates expr and throws an exception if it does not evaluate to
logical true.
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)
^Boolean (associative? coll)
Returns true if coll implements Associative
- source + source show types(bigfloat x)
^BigFloat (bigfloat x)
Coerce to BigFloat
- source + source show types(bigfloat? n)
^Boolean (bigfloat? n)
Returns true if n is a BigFloat
- source + source show types(bigint x)
^BigInt (bigint x)
Coerce to BigInt
- source + source show types(boolean x)
^Boolean (boolean x)
Coerce to boolean
- source + source show typesReturns 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.
If coll is counted? returns its count, else will count at most the first n
elements of coll using its seq
Returns true if x implements Callable. Note that many data structures
(e.g. sets and maps) implement Callable.
(chan n)
^Channel (chan ^Int n)
Returns a new channel with an optional buffer of size n.
- source + source show types(char x)
^Char (char x)
Coerce to char
- source + source show types(class x)
^Type (class x)
Returns the Type of x.
- source + source show types(coll? x)
^Boolean (coll? x)
Returns true if x implements Collection
- source + source show types(comment & body)
Ignores body, yields nil
- source + source(counted? coll)
^Boolean (counted? coll)
Returns true if coll implements count in constant time
- source + source show typesCreate 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)
^Seq (cycle ^Seqable coll)
Returns a lazy (infinite!) sequence of repetitions of the items in coll.
- source + source show types(declare & names)
defs the supplied var names with no bindings, useful for making forward declarations.
- source + source(dedupe coll)
^Seq (dedupe ^Seqable coll)
Returns a lazy sequence removing consecutive duplicates in coll.
- source + source show types(defmethod multifn dispatch-val & fn-tail)
Creates and installs a new method of multimethod associated with dispatch-value.
- source + source(defn- name & decls)
same as defn, yielding non-public def
- source + sourcedefs name to have the value of the expr if the named var is not bound,
else expr is unevaluated
(denominator r)
^Number (denominator ^Ratio r)
Returns the denominator part of a Ratio.
- source + source show typesAlso 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)
^Seq (distinct ^Seqable coll)
Returns a lazy sequence of the elements of coll with duplicates removed.
- source + source show types(distinct? x y & more)
^Boolean (distinct? x y & more)
Returns true if no two of the arguments are =
- source + source show typesRepeatedly executes body (presumably for side-effects) with
bindings and filtering as provided by "for". Does not retain
the head of the sequence. Returns nil.
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)
^Double (double ^Number x)
Coerce to double
- source + source show types(drop n coll)
^Seq (drop ^Number n ^Seqable coll)
Returns a lazy sequence of all but the first n items in coll.
- source + source show types(drop-last n s)
^Seq (drop-last ^Number n ^Seqable s)
Return a lazy sequence of all but the last n (default 1) items in coll
- source + source show typesReturns a lazy sequence of the items in coll starting from the first
item for which (pred item) returns logical false.
(empty coll)
^Collection (empty coll)
Returns an empty collection of the same category as coll, or nil
- source + source show typesReturns 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 + sourceReturns true if (pred x) is logical true for every x in coll, else
false.
Returns the cause of ex if ex is an ExInfo.
Otherwise returns nil.
Returns exception data (a map) if ex is an ExInfo.
Otherwise returns nil.
Returns the message attached to ex if ex is an ExInfo.
Otherwise returns nil.
(exit code)
(exit ^Int code)
Causes the current program to exit with the given status code (defaults to 0).
- source + source show typesReturns a lazy sequence of the items in coll for which
(pred item) returns true. pred must be free of side-effects.
Returns a vector of the items in coll for which
(pred item) returns true. pred must be free of side-effects.
(find-ns sym)
^Namespace (find-ns ^Symbol sym)
Returns the namespace named by the symbol or nil if it doesn't exist.
- source + source show typesReturns the global var named by the namespace-qualified symbol, or
nil if no var with that name.
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)
^Boolean (float? n)
Returns true if n is a floating point number
- source + source show typesFlushes the output stream that is the current value of
*out*
(fn? x)
^Boolean (fn? x)
Returns true if x is Fn, i.e. is an object created via fn.
- source + source show types(format fmt & args)
^String (format ^String fmt & args)
Formats a string using fmt.Sprintf
- source + source show typesReturns a map from distinct items in coll to the number of times
they appear.
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.
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
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)
^Int (hash x)
Returns the hash code of its argument.
- source + source show types(in-ns name)
^Namespace (in-ns ^Symbol name)
Sets *ns* to the namespace named by the symbol, creating it if needed.
- source + source show types(indexed? coll)
^Boolean (indexed? coll)
Return true if coll implements Indexed, indicating efficient lookup by index
- source + source show types(interleave c1 c2 & colls)
^Seq (interleave ^Seqable c1 ^Seqable c2 & colls)
Returns a lazy seq of the first item in each coll, then the second etc.
- source + source show typesReturns a lazy seq of the elements of coll separated by sep.
Returns a stateful transducer when no collection is provided.
Returns a new coll consisting of to-coll with all of the items of
from-coll conjoined.
(iterate f x)
^Seq (iterate ^Callable f x)
Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects
- source + source show types(joker-version)
^String (joker-version)
Returns joker version as a printable string.
- source + source show typesReturns 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.
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.
Returns the lines of text from rdr as a lazy sequence of strings.
rdr must be File or BufferedReader.
(list? x)
^Boolean (list? x)
Returns true if x is a List
- source + source show typesLoads code from libs, throwing error if cyclic dependency detected,
and ignoring libs already being loaded.
(load-file f)
^Nil (load-file ^String f)
Loads code from file f. Does not protect against recursion.
- source + source show typesSequentially read and evaluate the set of forms contained in the
string
(loaded-libs)
^MapSet (loaded-libs)
Returns an UNSORTED set of symbols naming the currently loaded libs
- source + source show typesEvaluates 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.
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 + sourceReturns the result of applying concat to the result of applying map
to f and colls. Thus function f should return a collection.
(max-key k x y & more)
(max-key ^Callable k x y & more)
Returns the x for which (k x), a number, is greatest.
- source + source show typesReturns 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.
(methods multifn)
^Map (methods multifn)
Given a multimethod, returns a map of dispatch values -> dispatch fns
- source + source show types(min-key k x y & more)
(min-key ^Callable k x y & more)
Returns the x for which (k x), a number, is least.
- source + source show types(mod num div)
^Number (mod ^Number num ^Number div)
Modulus of num and div. Truncates toward negative infinity.
- source + source show types(newline)
^Nil (newline)
Writes a platform-specific newline to *out*
- source + source show typesReturns false if (pred x) is logical true for any x in coll,
else true.
(not-empty coll)
^Seqable (not-empty ^Seqable coll)
If coll is empty, returns nil, else coll
- source + source show typesReturns false if (pred x) is logical true for every x in
coll, else true.
(ns-aliases ns)
^Map (ns-aliases ns)
Returns a map of the aliases for the namespace.
- source + source show types(ns-interns ns)
^Map (ns-interns ns)
Returns a map of the intern mappings for the namespace.
- source + source show types(ns-map ns)
^Map (ns-map ns)
Returns a map of all the mappings for the namespace.
- source + source show types(ns-name ns)
^Symbol (ns-name ns)
Returns the name of the namespace, a symbol.
- source + source show types(ns-publics ns)
^Map (ns-publics ns)
Returns a map of the public intern mappings for the namespace.
- source + source show types(ns-refers ns)
^Map (ns-refers ns)
Returns a map of the refer mappings for the namespace.
- source + source show types(ns-unalias ns sym)
^Nil (ns-unalias ns ^Symbol sym)
Removes the alias for the symbol from the namespace.
- source + source show types(ns-unmap ns sym)
^Nil (ns-unmap ns ^Symbol sym)
Removes the mappings for the symbol from the namespace.
- source + source show types(nthnext coll n)
^Seq (nthnext ^Seqable coll ^Number n)
Returns the nth next of coll, (seq coll) when n is 0.
- source + source show types(nthrest coll n)
^Seq (nthrest ^Seqable coll ^Number n)
Returns the nth rest of coll, coll when n is 0.
- source + source show types(num x)
^Number (num ^Number x)
Coerce to Number
- source + source show types(number? x)
^Boolean (number? x)
Returns true if x is a Number
- source + source show types(numerator r)
^Number (numerator ^Ratio r)
Returns the numerator part of a Ratio.
- source + source show typesTakes 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.
Returns a lazy sequence of lists like partition, but may include
partitions with fewer than n items at the end.
Applies f to each value in coll, splitting it each time f returns a
new value. Returns a lazy seq of partitions.
(pprint x)
^Nil (pprint x)
Pretty prints x to the output stream that is the current value of *out*.
- source + source show types(pr-err & xs)
^Nil (pr-err & xs)
pr to *err*
- source + source show types(pr-str & xs)
^String (pr-str & xs)
pr to a string, returning it
- source + source show typesCauses the multimethod to prefer matches of dispatch-val-x over dispatch-val-y
when there is a conflict
(prefers multifn)
^Map (prefers multifn)
Given a multimethod, returns a map of preferred value -> set of other values
- source + source show typesPrints 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)
^Nil (print-err & xs)
print to *err*
- source + source show types(print-str & xs)
^String (print-str & xs)
print to a string, returning it
- source + source show types(printf fmt & args)
^Nil (printf ^String fmt & args)
Prints formatted output, as per format
- source + source show types(println & more)
^Nil (println & more)
Same as print followed by (newline)
- source + source show types(println-err & xs)
^Nil (println-err & xs)
println to *err*
- source + source show types(println-str & xs)
^String (println-str & xs)
println to a string, returning it
- source + source show types(prn & more)
^Nil (prn & more)
Same as pr followed by (newline). Observes *flush-on-newline*
- source + source show types(prn-err & xs)
^Nil (prn-err & xs)
prn to *err*
- source + source show types(prn-str & xs)
^String (prn-str & xs)
prn to a string, returning it
- source + source show typesReturns a random floating point number between 0 (inclusive) and
n (default 1) (exclusive).
(rand-int n)
^Int (rand-int ^Number n)
Returns a random integer between 0 (inclusive) and n (exclusive).
- source + source show typesReturn a random element of the (sequential) collection. Will have
the same performance characteristics as nth for the given
collection.
Returns items from coll with random probability of prob (0.0 -
1.0).
(ratio? n)
^Boolean (ratio? n)
Returns true if n is a Ratio
- source + source show types(rational? n)
^Boolean (rational? n)
Returns true if n is a rational number
- source + source show types(re-find re s)
(re-find ^Regex re ^String s)
Returns the leftmost regex match, if any, of string to pattern.
- source + source show types(re-matches re s)
(re-matches ^Regex re ^String s)
Returns the match, if any, of string to pattern.
- source + source show types(re-pattern s)
^Regex (re-pattern s)
Returns an instance of Regex
- source + source show types(re-seq re s)
^Seq (re-seq ^Regex re ^String s)
Returns a sequence of successive matches of pattern in string
- source + source show types(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)
^Boolean (realized? ^Pending x)
Returns true if a value has been produced for a delay or lazy sequence.
- source + source show typesReturns a lazy seq of the intermediate values of the reduction (as
per reduce) of coll by f, starting with init.
(refer-clojure & filters)
Same as (refer 'joker.core <filters>)
- source + sourceReturns 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 + source(remove-method multifn dispatch-val)
Removes the method of multimethod associated with dispatch-value.
- source + sourceRemoves the namespace named by the symbol. Use with caution.
Cannot be used to remove the clojure namespace.
(repeat n x)
^Seq (repeat ^Number n x)
Returns a lazy (infinite!, or length n if supplied) sequence of xs.
- source + source show typesTakes a function of no args, presumably with side effects, and
returns an infinite (or length n if supplied) lazy sequence of calls
to it
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.
Resolves namespace-qualified sym per 'resolve'. If initial resolve
fails, attempts to require sym's namespace and retries.
Sets the value of atom to newval without regard for the
current value. Returns newval.
(reset-meta! ref metadata-map)
(reset-meta! ^Ref ref ^Map metadata-map)
Atomically resets the metadata for a namespace/var/atom
- source + source show typesSets the value of atom to newval. Returns [old new], the value of the
atom before and after the reset.
(resolve env sym)
^Var (resolve ^Gettable env ^Symbol sym)
Same as (ns-resolve *ns* sym) or (ns-resolve *ns* env sym)
- source + source show types(reversible? coll)
^Boolean (reversible? coll)
Returns true if coll implements Reversible
- source + source show typesRuns the supplied procedure (via reduce), for purposes of side
effects, on successive items in the collection. Returns nil.
(seqable? x)
^Boolean (seqable? x)
Return true if the seq function is supported for x
- source + source show typesCoerces coll to a (possibly empty) sequence, if it is not already
one. Will not force a lazy seq. (sequence nil) yields ()
(sequential? coll)
^Boolean (sequential? coll)
Returns true if coll implements Sequential
- source + source show types(set coll)
^MapSet (set ^Seqable coll)
Returns a set of the distinct elements of coll.
- source + source show types(set? x)
^Boolean (set? x)
Returns true if x implements Set
- source + source show types(shuffle coll)
^Vector (shuffle coll)
Return a random permutation of coll
- source + source show typesOpens file f and reads all its contents, returning a string.
f can be a string (filename) or a reader object like *in* or
the one returned by joker.os/open.
When expr is not nil, threads it into the first form (via ->),
and when that result is not nil, through the next etc.
When expr is not nil, threads it into the first form (via ->>),
and when that result is not nil, through the next etc.
Returns a sorted sequence of the items in coll. If no comparator is
supplied, uses compare.
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)
^Boolean (special-symbol? s)
Returns true if s names a special form
- source + source show types(split-at n coll)
^Vector (split-at ^Number n ^Seqable coll)
Returns a vector of [(take n coll) (drop n coll)]
- source + source show types(split-with pred coll)
^Vector (split-with ^Callable pred ^Seqable coll)
Returns a vector of [(take-while pred coll) (drop-while pred coll)]
- source + source show typesReturns the substring of s beginning at start inclusive, and ending
at end (defaults to length of string), exclusive.
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args).
Returns the value that was swapped in.
Returns a lazy sequence of the first n items in coll, or all items if
there are fewer than n.
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)
^Seq (take-nth ^Number n ^Seqable coll)
Returns a lazy seq of every nth item in coll.
- source + source show typesReturns a lazy sequence of successive items from coll while
(pred item) returns true. pred must be free of side-effects.
test [v] finds fn at key :test in var metadata and calls it,
presuming failure will throw exception
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(type x)
^Type (type x)
Returns the :type metadata of x, or its Type if none
- source + source show types(var-get x)
(var-get ^Var x)
Gets the value in the var object
- source + source show types(var-set x val)
(var-set ^Var x val)
Sets the value in the var object to val.
- source + source show types(var? v)
^Boolean (var? v)
Returns true if v is of type Var
- source + source show typesbindings => x xs
Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once
Repeatedly executes body while test expression is true. Presumes
some side-effect will cause test to become false/nil. Returns nil
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.
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.
Evaluates body in a context in which *in* is bound to a fresh
Buffer initialized with the string s.
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)
^Seq (xml-seq root)
A tree seq on the xml elements as per xml/parse
- source + source show types(zipmap keys vals)
^Map (zipmap ^Seqable keys ^Seqable vals)
Returns a map with the keys mapped to the corresponding vals.
- source + source show types