clj_rt
General functions used during runtime.
This modules is analougous to theclojure.lang.RT
class. The
modules here are used in places where we can't yet rely on the
clojure.core
being there (e.g. clj_reader
).
Summary
Functions
-
apply(Fn, Args)
Applies the argument to the functions assuming
Fn
implements'clojerl.IFn'
. -
assoc(Map, Key, Value)
assoc[iate].
-
associative?(X)
Returns true if
X
implements'clojerl.IAssociative'
. -
boolean(X1)
Coerce to boolean.
-
boolean?(X)
Returns true if
X
is a'clojerl.Boolean'
. -
byte(X)
Coerce to byte.
-
char(X)
Coerce to char.
-
char?(X1)
Returns true if
X
is a BEAM binary with a single UTF-8 character. -
clj->erl(X, Recursive)
Returns the Erlang representation of x when it implements IEncodeErlang.
-
coll?(X)
Returns true if
X
implements'clojerl.IColl'
. -
compare_fun(Fun, X2)
Converts the provided
Fun
into a compatibleerlang
orclojure
compare function. -
conj(Coll, Item)
conj[oin].
-
cons(Item, Seq)
Returns a new seq where x is the first element and seq is the rest.
-
contains?(Coll, Key)
Returns true if key is present in the given collection, otherwise returns false.
-
count(Seq)
Returns the number of items in the collection.
-
deref(X)
Fetches the value referenced by
X
. -
disj(Coll, Item)
disj[oin].
-
dissoc(Map, Key)
dissoc[iate].
-
empty(Coll)
Returns an empty collection of the same category as coll, or nil.
-
empty?(Seq)
Returns true if coll has no items.
-
equiv(X, Y)
Equality.
-
erl->clj(X, Recursive)
"Returns the Clojure representation of x when it implements IEncodeClojure.
-
even?(X)
Returns true if n is even, throws an exception if n is not an integer.
-
find(Map, Key)
Returns the map entry for key, or nil if key not present.
-
first(Seq)
Returns the first item in the collection.
-
fourth(Seq)
Same as (first (next (next (next x)))).
-
gensym()
Equivalent to
gensym(<<"G__">>)
. -
gensym(Prefix)
Generates a new symbol unique to the current process using
Prefix
. -
get(X, Key)
Returns the value mapped to
Key
, or nil ifKey
is not present. -
get(X, Key, NotFound)
Returns the value mapped to
Key
, orNotFound
ifKey
is not present. -
hash(X)
Returns the hash code of its argument.
-
hash_map(Items)
Returns a new hash map with supplied mappings.
-
hash_set(Items)
Returns a new hash set with supplied items.
-
keys(X)
Returns a sequence of the map's keys, in the same order as (seq map).
-
keyword(Name)
Returns a keyword with the given name.
-
keyword(Namespace, Name)
Returns a keyword with the given name.
-
keyword?(X)
Returns true if
X
is a'clojerl.Keyword'
. -
list(Items)
Creates a new list containing the items.
-
list?(X)
Returns true if
X
is a'clojerl.List'
. -
load(ScriptBase)
Equivalent to
load(ScriptBase, true)
. -
load(ScriptBase, FailIfNotFound)
Attempts to load a Clojure script.
-
load_script(ScriptName, FailIfNotFound)
Attempts to load a Clojure script.
-
map?(X)
Returns true if
X
implements'clojerl.IMap'
. -
merge(Maps)
Returns a map that consists of the rest of the maps conj-ed onto the first.
-
meta(X)
Returns the metadata of obj, returns nil if there is no metadata.
-
meta?(X)
Returns true if
X
implements'clojerl.IMeta'
. -
name(X)
Returns the name String of a string, symbol or keyword.
-
namespace(X)
Returns the namespace String of a symbol or keyword, or nil if not present.
-
next(Seq)
Returns a seq of the items after the first.
-
next_id()
Returns the next id from the local process gensym counter.
-
nil?(X)
Returns true if
X
is nil. -
nth(Coll, N)
Returns the value at the index.
-
nth(Coll, N, NotFound)
Returns the value at the index or
NotFound
ofN
is invalid. -
number?(X)
Returns true if
X
is a number. -
peek(Stack)
For a list or queue, same as first, for a vector, same as, but much more efficient than, last.
-
pop(Stack)
For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item.
-
print(X, Writer)
Prints
X
toWriter` using `clojure.core/pr-on
when initialized or a fallback implementation otherwise. -
print_str(X)
Returns the string representation of
X
usingclojure.core/pr-on
when initialized or a fallback implementation otherwise. -
record?(X)
Returns true if
X
implements'clojerl.IRecord'
. -
regex?(X)
Returns true if
X
is a'erlang.util.Regex'
. -
reset_id()
Resets this local process gensym counter.
-
rest(Seq)
Returns a possibly empty seq of the items after the first.
-
second(Seq)
Same as (first (next x)).
-
seq(Seqable)
Returns a seq on the collection.
-
seq?(X)
Returns true if
X
implements'clojerl.ISeq'
. - seq_or_else(Seqable)
-
sequential?(X)
Returns true if
X
implements'clojerl.ISequential'
. -
set!(Var, Value)
Changes the dynamically bound value for
Var
. -
set?(X)
Returns true if
X
implements'clojerl.ISet'
. -
short(X)
Coerce to short.
-
shuffle(Seq)
Return a random permutation of coll.
-
str(X)
Returns the string representation of
X
by applying'clojerl.IStringable':str/1
. -
string?(X)
Returns true if
X
is a'clojerl.String'
. -
subvec(Vector, Start, End)
Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive).
-
symbol(Name)
Returns a Symbol with the given name.
-
symbol(Namespace, Name)
Returns a Symbol with the given namespace and name.
-
symbol?(X)
Returns true if
X
is a'clojerl.Symbol'
. -
third(Seq)
Same as (first (next (next x))).
-
to_list(List)
Converts the collection into an Erlang list.
-
type(X)
Returns the
'erlang.Type'
forX
. -
type?(X)
Returns true if
X
implements'clojerl.IType'
. -
type_module(X)
Returns the module name for
X
's type. -
vals(X)
Returns a sequence of the map's values, in the same order as (seq map).
-
var?(X)
Returns true if
X
is a'clojerl.Var'
. -
vector(Items)
Creates a new vector containing the items.
-
vector?(X)
Returns true if
X
implements'clojerl.IVector'
. -
with_meta(T, Meta)
Returns an object of the same type and value as
X
, with mapMeta
as its metadata.
Functions
apply(Fn, Args)
-spec apply('clojerl.IFn':type(), 'clojerl.ISequential':type()) -> any().
Applies the argument to the functions assuming Fn
implements
'clojerl.IFn'
.
assoc(Map, Key, Value)
-spec assoc('clojerl.IAssociative':type(), any(), any()) ->
'clojerl.IAssociative':type().
assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index.
associative?(X)
-spec 'associative?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IAssociative'
.
boolean(X1)
-spec boolean(any()) -> boolean().
Coerce to boolean.
boolean?(X)
-spec 'boolean?'(any()) -> boolean().
Returns true if X
is a 'clojerl.Boolean'
.
byte(X)
-spec byte(number()) -> integer().
Coerce to byte.
char(X)
-spec char(integer()) -> binary().
Coerce to char.
char?(X1)
-spec 'char?'(any()) -> boolean().
Returns true if X
is a BEAM binary with a single UTF-8
character.
clj->erl(X, Recursive)
-spec 'clj->erl'(any(), boolean()) -> any().
Returns the Erlang representation of x when it implements IEncodeErlang.
coll?(X)
-spec 'coll?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IColl'
.
compare_fun(Fun, X2)
-spec compare_fun('erlang.Fn':type(), erlang | clojure) -> function().
Converts the provided Fun
into a compatible erlang
or
clojure
compare function.
conj(Coll, Item)
-spec conj(any(), any()) -> any().
conj[oin]. Returns a new collection with the xs 'added'.
cons(Item, Seq)
-spec cons(any(), any()) ->
'clojerl.Cons':type() | 'clojerl.List':type().
Returns a new seq where x is the first element and seq is the rest.
contains?(Coll, Key)
-spec 'contains?'(any(), any()) -> boolean().
Returns true if key is present in the given collection, otherwise returns false.
count(Seq)
-spec count(any()) -> integer().
Returns the number of items in the collection.
deref(X)
-spec deref(any()) -> any().
Fetches the value referenced by X
.
X
needs to implement 'clojerl.IDeref'
(e.g. 'clojerl.Var'
,
'clojerl.Atom'
or 'clojerl.Agent'
).
disj(Coll, Item)
-spec disj(any(), any()) -> any().
disj[oin]. Returns a new set of the same (hashed/sorted) type, that does not contain key(s).
dissoc(Map, Key)
-spec dissoc('clojerl.IMap':type(), any()) -> 'clojerl.IMap':type().
dissoc[iate]. Returns a new map of the same (hashed/sorted) type, that does not contain a mapping for key(s).
empty(Coll)
-spec empty(any()) -> any().
Returns an empty collection of the same category as coll, or nil.
empty?(Seq)
-spec 'empty?'(any()) -> boolean().
Returns true if coll has no items.
equiv(X, Y)
-spec equiv(any(), any()) -> boolean().
Equality. Returns true if x equals y, false if not.
erl->clj(X, Recursive)
-spec 'erl->clj'(any(), boolean()) -> any().
"Returns the Clojure representation of x when it implements IEncodeClojure.
even?(X)
-spec 'even?'(integer()) -> boolean().
Returns true if n is even, throws an exception if n is not an integer
find(Map, Key)
-spec find(any(), any()) -> any().
Returns the map entry for key, or nil if key not present.
first(Seq)
-spec first(any()) -> any().
Returns the first item in the collection.
fourth(Seq)
-spec fourth(any()) -> any().
Same as (first (next (next (next x)))).
gensym()
-spec gensym() -> 'clojer.Symbol':type().
Equivalent to gensym(<<"G__">>)
.
gensym(Prefix)
-spec gensym(binary()) -> 'clojer.Symbol':type().
Generates a new symbol unique to the current process using
Prefix
.
get(X, Key)
-spec get(any(), any()) -> any().
Returns the value mapped to Key
, or nil if Key
is not
present.
get(X, Key, NotFound)
-spec get(any(), any(), any()) -> any().
Returns the value mapped to Key
, or NotFound
if Key
is not
present.
hash(X)
-spec hash(any()) -> integer().
Returns the hash code of its argument.
hash_map(Items)
-spec hash_map(list()) -> 'clojerl.Map':type().
Returns a new hash map with supplied mappings.
hash_set(Items)
-spec hash_set(list()) -> 'clojerl.Set':type().
Returns a new hash set with supplied items.
keys(X)
-spec keys('clojerl.IMap':type()) -> list().
Returns a sequence of the map's keys, in the same order as (seq map).
keyword(Name)
-spec keyword('clojerl.Symbol':type() | binary()) ->
'clojerl.Keyword':type().
Returns a keyword with the given name.
Do not use : in the keyword strings, it will be added automatically.
keyword(Namespace, Name)
-spec keyword(binary(), binary()) -> 'clojerl.Keyword':type().
Returns a keyword with the given name.
Do not use : in the keyword strings, it will be added automatically.
keyword?(X)
-spec 'keyword?'(any()) -> boolean().
Returns true if X
is a 'clojerl.Keyword'
.
list(Items)
-spec list(any()) -> 'clojerl.List':type().
Creates a new list containing the items.
list?(X)
-spec 'list?'(any()) -> boolean().
Returns true if X
is a 'clojerl.List'
.
load(ScriptBase)
-spec load(binary()) -> undefined.
Equivalent to load(ScriptBase, true)
.
load(ScriptBase, FailIfNotFound)
-spec load(binary(), boolean()) -> undefined.
Attempts to load a Clojure script.
ScriptBase
is used to resolve the location of a file in the code
path with either the .clje
or .cljc
extension.
FailIfNotFound
is true
generates an error if the file
cannot be found.
load_script(ScriptName, FailIfNotFound)
-spec load_script(binary(), boolean()) -> any().
Attempts to load a Clojure script.
ScriptBase
is used to resolve the location of a file in the code
path.
FailIfNotFound
is true
generates an error if the file
cannot be found.
map?(X)
-spec 'map?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IMap'
.
merge(Maps)
-spec merge([any()]) -> any().
Returns a map that consists of the rest of the maps conj-ed onto the first.
meta(X)
-spec meta(any()) -> any().
Returns the metadata of obj, returns nil if there is no metadata.
meta?(X)
-spec 'meta?'(any()) -> any().
Returns true if X
implements 'clojerl.IMeta'
.
name(X)
-spec name(any()) -> binary() | undefined.
Returns the name String of a string, symbol or keyword.
namespace(X)
-spec namespace(any()) -> binary() | undefined.
Returns the namespace String of a symbol or keyword, or nil if not present.
next(Seq)
-spec next(any()) -> any().
Returns a seq of the items after the first.
next_id()
-spec next_id() -> integer().
Returns the next id from the local process gensym counter.
nil?(X)
-spec 'nil?'(any()) -> boolean().
Returns true if X
is nil.
nth(Coll, N)
-spec nth(any(), integer()) -> any().
Returns the value at the index.
nth(Coll, N, NotFound)
-spec nth(any(), integer(), any()) -> any().
Returns the value at the index or NotFound
of N
is invalid.
number?(X)
-spec 'number?'(any()) -> boolean().
Returns true if X
is a number.
peek(Stack)
-spec peek(any()) -> any().
For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil.
pop(Stack)
-spec pop(any()) -> any().
For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the same as next/butlast.
print(X, Writer)
-spec print(any(), 'erlang.io.IWriter':type()) -> undefined.
Prints X
to Writer` using `clojure.core/pr-on
when
initialized or a fallback implementation otherwise.
print_str(X)
-spec print_str(any()) -> undefined.
Returns the string representation of X
using
clojure.core/pr-on
when initialized or a fallback implementation
otherwise.
record?(X)
-spec 'record?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IRecord'
.
regex?(X)
-spec 'regex?'(any()) -> boolean().
Returns true if X
is a 'erlang.util.Regex'
.
reset_id()
-spec reset_id() -> ok.
Resets this local process gensym counter.
rest(Seq)
-spec rest(any()) -> any().
Returns a possibly empty seq of the items after the first.
second(Seq)
-spec second(any()) -> any().
Same as (first (next x)).
seq(Seqable)
-spec seq(any()) -> any() | undefined.
Returns a seq on the collection.
seq?(X)
-spec 'seq?'(any()) -> boolean().
Returns true if X
implements 'clojerl.ISeq'
.
seq_or_else(Seqable)
-spec seq_or_else(any()) -> any() | undefined.
Returns Seqable
if applying seq/1
is not nil
,
otherwise returns nil
.
sequential?(X)
-spec 'sequential?'(any()) -> boolean().
Returns true if X
implements 'clojerl.ISequential'
.
set!(Var, Value)
-spec 'set!'('clojerl.Var':type(), any()) -> any().
Changes the dynamically bound value for Var
.
set?(X)
-spec 'set?'(any()) -> boolean().
Returns true if X
implements 'clojerl.ISet'
.
short(X)
-spec short(number()) -> integer().
Coerce to short.
shuffle(Seq)
-spec shuffle(any()) -> [any()].
Return a random permutation of coll
str(X)
-spec str(any()) -> binary().
Returns the string representation of X
by applying 'clojerl.IStringable':str/1
.
string?(X)
-spec 'string?'(any()) -> boolean().
Returns true if X
is a 'clojerl.String'
.
subvec(Vector, Start, End)
-spec subvec('clojerl.Vector':type(), integer(), integer()) ->
'clojerl.Vector':type().
Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive).
symbol(Name)
-spec symbol(binary()) -> 'clojerl.Symbol':type().
Returns a Symbol with the given name.
symbol(Namespace, Name)
-spec symbol(binary(), binary()) -> 'clojerl.Symbol':type().
Returns a Symbol with the given namespace and name.
symbol?(X)
-spec 'symbol?'(any()) -> boolean().
Returns true if X
is a 'clojerl.Symbol'
.
third(Seq)
-spec third(any()) -> any().
Same as (first (next (next x))).
to_list(List)
-spec to_list(any()) -> [any()].
Converts the collection into an Erlang list.
type(X)
-spec type(any()) -> 'erlang.Type':type().
Returns the 'erlang.Type'
for X
.
type?(X)
-spec 'type?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IType'
.
type_module(X)
-spec type_module(any()) -> module().
Returns the module name for X
's type.
vals(X)
-spec vals('clojerl.IMap':type()) -> list().
Returns a sequence of the map's values, in the same order as (seq map).
var?(X)
-spec 'var?'(any()) -> boolean().
Returns true if X
is a 'clojerl.Var'
.
vector(Items)
-spec vector(list()) -> 'clojerl.Vector':type().
Creates a new vector containing the items.
vector?(X)
-spec 'vector?'(any()) -> boolean().
Returns true if X
implements 'clojerl.IVector'
.
with_meta(T, Meta)
-spec with_meta(T, map()) -> T.
Returns an object of the same type and value as X
, with map
Meta
as its metadata.