*state* | *state* | "Returns the current CVM state record. This is a large object, and should normally only be used temporarily to look up relevant values." |
values | values | "Gets the values from a map. Also see `keys`." |
number? | number? | "Returns `true` if and only if the argument is a numeric value." |
/ | / | "Double precision point divide. With a single argument, returns the reciprocal of a number. With multiple arguments, divides the first argument by the others in order." |
pow | pow | "Returns the first argument raised to the power of the second argument. Uses double precision maths." |
*origin* | *origin* | ["Similar to `*caller*` but returns the address of the account that initially signed this transaction." "In a chain of calls, this address is the very first link." "Usually, should NOT be used for access control, since a rogue actor can potentially trick a user into creating a transaction that allows code to be indirectly executed. Consider using `*caller*` for access control instead."] |
for-loop | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Executes a code body repeatedy while a condition is true. At the first iteration, `sym` is locally bound to the `init` value. For each subsequent iteration, sym is bound to the result of `change`. The result it the result of the last execution of `body`, or `nil` if no iterations were made." |
> | > | "Tests if numeric arguments are in strict decreasing order. Reads as 'greater-than'." |
update-in | (fn ([m ks f] (#8/assoc-in %0 %1 (%2 (#8/get-in %0 %1)))) ([m ks f x] (#8/assoc-in %0 %1 (%2 (#8/get-in %0 %1) %3))) ([m k f x & more] (#8/assoc-in %0 #8/ks (#8/apply %2 (#8/get-in %0 #8/ks) %4)))) | "Update a value in a nested associative data structure by applying a function." |
recur | recur | "Escapes from the currently executing code and recurs at the level of the next loop or function body." |
reduce | reduce | ["Reduces over a collection, calling `f` with an accumulator value and, successively each element of that collection." "Reduction can be finished by calling `reduced`. Otherwise, all elements in the collection are processed." "If accumulator is not initially supplied, the first element of the collection will be used."] |
sqrt | sqrt | "Computes the square root of a numerical argument. Uses double precision mathematics. May return `##NaN` for negative values." |
update | (fn ([m k f] (#8/assoc %0 %1 (%2 (#8/get %0 %1)))) ([m k f x] (#8/assoc %0 %1 (%2 (#8/get %0 %1) %3))) ([m k f x & more] (#8/assoc %0 %1 (#8/apply %2 (#8/get %0 %1) %4)))) | "Update a value in a associative data structure by applying a function." |
conj | conj | "Adds elements to a data structure, in the natural mode of addition for the data structure. Supports sequential collections, sets and maps. `nil` is treated as an empty vector." |
last | last | "Returns the last element of a Countable data structure, in collection-defined order." |
== | == | ["Tests if arguments are equal in numerical value." "Difference with `=` is that types are erased (eg. `Long` value is comparable with a `double` value)."] |
fail | fail | ["Causes execution to fail at the current position." "Error type defaults to `:ASSERT` if not specified, and cannot be nil. Typically a keyword, it can actually be any value." "Error message defaults to nil if not specified. The message may be any value, but the use of short descriptive strings is recommended."] |
= | = | "Returns `true` if and only if arguments are precisely equal in value." |
blob | blob | "Casts the argument to a canonical Blob. Arugment can be an Address, a hex String, a Long value, or another Blob value." |
or | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Executes expressions in sequence, returning the first truthy value, or the last value if all were falsey (false or nil)." "Does not evaluate later expressions, so can be used to short circuit execution." "Returns nil with no expressions present."] |
print | print | "Prints any value in its canonical readable representation as a String." |
set-memory | set-memory | "Sets the free memory allowance for the current account address, in number of bytes. Increases in memory allowance may cost coin balance. Decreases in memory allowance may earn a coin refund. Returns the price paid (negative for refund)." |
double? | double? | "Returnes `true` if the argument is a value of Double type, `false` otherwise." |
get-holding | get-holding | "Gets the holding value for a specified owner account address. Owner account must exist. Holding will be null by default. See `*holdings*`, `set-holding`." |
switch | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Switches on the result of an expression. Tests are computed in turn, based on equality, with an option default value, like `cond`." |
account | account | "Returns the account record for a given address, or `nil` if the account does not exist. Argument must be an Address." |
set? | set? | "Returns true if the argument is a set, false otherwise." |
not | not | "Inverts a truth value. Returns `true` for `false` or `nil`, returns `false` for any other value." |
macro | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Creates an anonymous macro function, suitable for use as an expander." |
into | into | "Adds elements to a collection, in a collection-defined manner as with `conj`." |
expand | expand | ["Expands the given form." "Uses the specified expander (including macros) as the primary expander if provided, the default `*initial-expander*` otherwise." "If also provided, a continuation expander will be passed to the primary expander, otherwise the primary will be used as its own continuation." "Expanders are an advanced feature."] |
long | long | "Casts the given argument to a 64-bit Long (signed integer)." |
return | return | "Exits from the currently executing function, returning the specified value. Expressions following `return` will not be executed." |
empty? | empty? | "Checks if the argument is an empty data structure. nil is considered empty. Returns false if not a data structures." |
*memory* | *memory* | "Returns the current memory allowance for this account. May be zero - in which case any new memory allocations will be charged at the current memory exchange pool price." |
resolve | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Resolves a value in CNS."] |
undef* | undef* | "Undefines a symbol, removing the mapping from the current environment if it exists. Helper function for the 'undef' macro." |
*timestamp* | *timestamp* | ["Returns the current timestamp." "The timestamp is a `Long` value that is equal to the greatest timestamp of any block executed (including the current block)." "A timestamp can be interpreted as the number of milliseconds since January 1, 1970, 00:00:00 GMT. The block timestamp should always be less than or equal to the Unix timestamp of peers that are in consensus." "Commonly used with `schedule`."] |
int | int | "Casts the given argument to an Integer)." |
nil? | nil? | "Returns `true` if and only if the argument is the value `nil`." |
map | map | "Applies a Function to each element of a data structure in sequence, and returns a vector of results. Additional collections may be provided to call a function with higher arity." |
count | count | "Returns the number of elements in the given data structure or other countable value." |
deploy | deploy | "Deploys an actor. The code provided will be executed to initialise the actor's account. More than one code form may be provided, in which case they will be compiled and evaluated separately. Returns the Address of the deployed actor." |
boolean | boolean | "Casts any value to a Boolean. Returns false if value is `nil` or `false`, true in any other case." |
boolean? | boolean? | "Returns true if the argument is a Boolean (either `true` or `false`). Any other value (including nil) returns false." |
dotimes | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Repeats execution of the body `count` times, binding the specified symbol from 0 to `(- count 1)` on successive iterations."] |
join | join | "Joins a sequence of Strings into a single String, using the provided Character separator." |
*memory-price* | *memory-price* | "Returns the current memory price, as a double value" |
*depth* | *depth* | ["Returns the CVM execution stack depth, at the point the `*depth*` operation is executed. If the depth becomes too deep, the transaction will fail with a `:DEPTH` exception." "In most cases, the allowable depth should be sufficient."] |
>= | >= | "Tests if numeric arguments are in decreasing order. Reads as 'greater-than-or-equal'." |
*signer* | *signer* | "Returns the public key used to sign the current transaction." |
!= | != | ["Tests if arguments are not equal in numerical value. Inverse of ==."] |
filterv | (fn [pred coll] (#8/reduce (fn [acc e] (cond (%0 %3) (#8/conj %2 %3) %2)) [] %1)) | ["Filters a collection by applying the given predicate to each element, returning a Vector." "Each element is included in the Vector if and only if the predicate returns a truthy value (anything but false or nil)."] |
*location* | *location* | "Returns the [block-index transaction-index] location of the current transaction." |
merge | merge | "Merges zero or more Maps (not Indexes!), replacing existing values. Nil is considered as an empty map." |
contains-key? | contains-key? | "Returns true if the given associative data structure contains the given key, false otherwise." |
inc | inc | "Increments the given Long value by 1." |
vector | vector | "Creates a vector with the given elements." |
actor? | (fn [addr] (cond (#8/address? %0) (let [act (#8/account %0) ] (cond %1 (#8/nil? (:key %1)) false)) false)) | "Returns true if the given address refers to an actor." |
hash-set | hash-set | "Constructs a Set with the given values. If a value is repeated, it will be included only once in the set." |
syntax | syntax | "Wraps a value as a syntax object, if it is not already one. If metadata is provided, merge the metadata into the resulting syntax object." |
address | address | "Casts the argument to an Address. Valid arguments are hex strings, a Long, an Address or a Blob with the correct length (8 bytes)." |
slice | slice | ["Takes a slice of a countable data structure between start (inclusive) and end (exclusive) indexes."] |
when-not | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Like `when` but the opposite: body is executed only if the result is false or nil." |
dissoc-in | (fn ([m ks] (cond (#8/empty? %1) %0 (let [[k & more] %1 ] (cond (#8/empty? %3) (#8/dissoc %0 %2) (let [nv (#8/dissoc-in (#8/get %0 %2) %3) ] (cond (#8/empty? %4) (#8/dissoc %0 %2) (#8/assoc %0 %2 %4)))))))) | "Dissocs from a nested associative data structure. If a nested result is empty? dissoc it as well." |
floor | floor | "Computes the mathematical floor (rounding down towards negative infinity) for a numerical argument. Uses double precision mathematics." |
create-peer | create-peer | "Creates a new peer record for the network. The peer must have an account number and sufficient balance to place a stake amount" |
cons | cons | "Constructs a List, by prepending the leading arguments to the last argument. The last argument must be coercable to a sequential data structure. `nil` is treated as an empty list." |
list? | list? | "Returns `true` if and only if the argument is a List." |
encoding | encoding | ["Returns the byte encoding for a given value as a Blob." "The encoding is the unique canonical binary representation of a value. Encodings may change between Convex versions - it is unwise to rely on the exact representation."] |
quote | quote | "Returns the quoted value of a form, without evaluating it. For example, you can quote a symbol to get the symbol itself rather than the value in the environment that it refers to." |
*sequence* | *sequence* | "Returns the sequence number for the current transaction. The sequence number is the number of transactions executed on this account *including* the current transaction / query. The next valid transction must increment *sequence* by one." |
unsyntax | unsyntax | "Unwraps a value from a syntax object. If the argument is not a syntax object, returns it unchanged." |
create-account | (fn [key] (do (cond (#8/blob? %0) *result* (#8/fail :CAST "create-account requires a blob key")) (#8/deploy (#8/list set-key %0)))) | "Creates an account with the specified account public key and returns its address." |
coll? | coll? | "Tests if the argument is a data struture." |
call* | call* | ["Behaves like `call` but implemented as a function. Instead of a form, takes a symbol referring to the function, and then arguments separately." "Same kind of errors may happen."] |
transfer | transfer | "Transfers the specified amount of coins to the target `Address`. Returns the amount transferred if successful, which may be less than the amount requested if the target does not accept all." |
first | first | "Returns the first element from a Countable collection which must contain at least one element. Also see `empty?`" |
quasiquote | (fn [[_ form] e] (#8/tailcall* %1 (#8/qq* %0 1) %1)) | "Returns the quoted value of a form, without evaluating it. Like `quote`, but elements within the form may be unquoted via `unquote`." |
apply | apply | ["Applies a function to the specified arguments, after flattening the last argument. Last argument must be a sequential collection, or 'nil' which is considered an empty collection." "Only useful in particular cases when interacting with variadic functions."] |
evict-peer | evict-peer | "Evicts a peer. Peer must be insufficiently staked, or controlled by this account" |
query-as | query-as | "Like `eval-as` but executes the code in a query context, discarding any state changes." |
defexpander | (fn [x e] (let [[_ name & decl] %0 exp (#8/cons fn %3) form (#8/list def (#8/syntax %2 (#8/hash-map :expander true)) %4) ] (#8/tailcall* %1 %5 %1))) | "Advanced feature. Defines an expander in the current environment." |
*holdings* | *holdings* | ["Returns the holdings Index for this account." "Holdings are data values controlled by other accounts (usually actors). They can be used to indicate that an account may have special rights or asset holdings with respect to a specific actor, for instance." "Holdings should NOT be trusted if they are provided by an untrusted account." "See `get-holding`, `set-holding`."] |
int? | int? | "Returnes `true` if the argument is an Integer value, `false` otherwise." |
schedule | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Schedules a transaction for future execution under this account. Expands and compiles code now, but does not execute until the specified timestamp." |
balance | balance | "Returns the Convex Coin balance of the specified Account, which must be identified with a valid `Address`. Returns `nil` if and only if the Account does not exist." |
eval-as | eval-as | "Like `eval` but evaluates code in the environment of the specifed account. The current account must have controller privileges to execute this operation (see `set-controller`)." |
tailcall* | tailcall* | "Like `tailcall` but lower-level. Instead of a form, takes a function and then arguments separately." |
+ | + | "Adds numerical arguments. Result will be a `Long` if all arguments are integers, or a double if any floating point values are included." |
mapv | (fn [f fst & more] (#8/apply #8/map %0 (#8/vec %1) %2)) | "Like `map` but systematically returns the result as a vector." |
difference | difference | "Computes the difference of one or more sets. Nil arguments are treated as an empty set." |
byte | byte | "Casts a value to the unsigned byte range 0-255. Discards high bits of larger integer / blob types." |
symbol | symbol | "Creates a symbol from keyword, a symbol, or a string between 1 and 64 character" |
rollback | rollback | "Escapes from the currently executing smart contract. Rolls back any state changes, as if nothing happened during that transaction. Returns the given value." |
assoc | assoc | "Adds entries into an associative data structure, taking each two arguments as key/value pairs. A nil data structure is considered as an empty map. A set can only take the boolean values (`true` and `false`) indicating set inclusion and exclusion respectively." |
fn? | fn? | "Returns `true` if and only if the argument is a function. Some values may operate as functions but are not functions themselves (eg. maps and vectors)." |
index | index | ["Creates an Index. Indexes are specialised maps that support blob-like types as keys only (see `blob`)." "Optional arguments must be pairs of blob-like keys and values to be included in the blob map."] |
max | max | "Returns the numerical maximum of the given values. If two or more values are equal to the minimum, the first is returned." |
*balance* | *balance* | ["Returns the available balance of the current account (in Convex coins)." "The available balance excludes reserved balance for transaction execution, so this number may be somewhat less than the total account balance during transaction execution."] |
eval | eval | "Evaluates code in the current context, expanding and compiling the form if necessary (see `expand`,`compile`)." |
set-parent | set-parent | ["Sets the parent for the current account." "Parent account is the account to which symbolic lookups will default."] |
nan? | nan? | "Returns `true` if and only if the argment is the Double value `##NaN`." |
assert | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Evaluates each test (a form), and raises an `:ASSERT` error if any are not truthy." |
name | name | "Gets the String name of an object: a Keyword, a Symbol, or a String." |
quot | quot | "Returns the quotient of a numerator divided by a divisor. Performs truncated division (ie. rounds towards zero)." |
log | log | ["Outputs a sequence of values to the CVM log for the current account. Any valid CVM values can be logged. Returns a vector containing logged values." "The CVM log is NOT stored on chain. It may be used by peers for external audits."] |
sha256 | sha256 | "Calculates the 32-byte SHA-256 cryptographic hash of a `blob` or an `address` (which is a specialized type of `blob`). Returns a 32-byte `blob`." |
split | split | "Splits a string by the given character separator, returning a Vector of substrings excluding the separator(s). Separator may be a character, Long codepoint value or a 1-character UTF-8 String." |
address? | address? | "Returns true if the argument is an actual `address`." |
set-stake | set-stake | "Sets the delegated stake on a given peer. Peer must exist, and funds must be available to set the stake to the specified level. Setting stake to zero removes the stake entirely." |
syntax? | syntax? | "Returns true if the argument is a syntax object." |
mapcat | (fn [f coll & more] (#8/apply #8/concat (#8/empty %1) (#8/apply #8/map %0 %1 %2))) | "Maps a function across the given collections, then concatenates the results. Nil is treated as an empty collection. See `map`." |
*juice* | *juice* | ["Returns the amount of execution juice consumed at this point of the current transaction." "Juice is required for every CVM operation executed, and the transaction will fail immediately with a `:JUICE` error if an attempt is made to consume juice beyond this value."] |
*initial-expander* | *initial-expander* | "Initial expander used to expand forms, before compilation." |
*offer* | *offer* | "Returns the amount of native coin offered by `*caller*` during a call. See `call`. Will usually be zero, unless the caller has included an offer with a 'call' expression." |
defmacro | (fn [x e] (let [[_ name & decl] %0 mac (#8/cons fn %3) form (#8/list def (#8/syntax %2 (#8/assoc (#8/meta (#8/first %3)) :expander true)) (#8/list let (vector m# %4) (fn [x e] (tailcall* e (apply m# (next x)) e)))) ] (#8/tailcall* %1 %5 %1))) | ["Like `defn` but defines a macro instead of a regular function." "A macro is a special function that is executed at expansion, before compilation, and produces valid Convex Lisp code for subsequent execution."] |
lookup-meta | lookup-meta | "Looks up metadata for a Symbol in the current execution environment, or the Account of the given Address if specified. Returns nil if not found." |
list | list | "Creates a List containing the given arguments as elements." |
zero? | zero? | "Returns true if the argument has the numeric value zero, false otherwise." |
dec | dec | "Decrements the given Integer by 1." |
expand-1 | (fn ([x] (#8/expand %0 #8/*initial-expander* #8/identity)) ([x e] (#8/expand %0 %1 #8/identity))) | "Expands a form once." |
fn | fn | "Creates an anonymous function (closure) with the specified argument list and function body. Will close over variables in the current lexical scope." |
set-holding | set-holding | "Sets the holding value for a specified address. Returns the new holding value." |
import | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Imports a library for use in the current environment." "Creates an alias to the library so that symbols defined in the library can be addressed directly in the form 'alias/symbol-name'." "Returns the address of the imported account."] |
* | * | "Multiplies numeric arguments. Result will be a `Double` if any arguments are floating point values, otherwise it will be a `long`." |
second | second | "Returns the second element of a countable collection." |
compile | compile | "Compiles a form, returning an Op. See `eval`." |
*caller* | *caller* | "During an actor call, returns the address of the account doing the call. Returns `nil` otherwise." |
reverse | reverse | "Reverses a sequential data structure. Lists are converted to vectors, and vice versa for efficieny reasons. Nil is treated as an empty vector." |
mod | mod | "Returns the integer modulus of a numerator divided by a divisor. The result will always be positive, consistent with Euclidean Divsion." |
define | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Defines a value in the current environment, like def, but at expand time." |
account? | (fn [addr] (cond (#8/address? %0) (#8/boolean (#8/account %0)) false)) | "Returns true if the given address refers to an existing actor or user account, false otherwise." |
loop | loop | ["Creates a loop body, binding one or more loop variables in a manner similar to `let`." "Within the loop body, `recur` can be used to return to the start of the loop while re-binding the loop variables with new values. Does not consume stack."] |
subset? | subset? | "Returns true if `set-1` is a subset of `set-2`. Both arguments must be sets, nil being considered as an empty set." |
str | str | "Coerces values into strings and concatenates them." |
symbol? | symbol? | "Returns true if the argument is a symbol, false otherwise." |
concat | concat | "Concatenates sequential data structures, returning a new sequential data structure of the same type as the first non-nil argument. `nil` is treated as an empty sequence." |
*result* | *result* | "Returns the result of the last CVM operation executed. Can be used, in some cases, to access the value of the previous expression. Will be nil for new transactions, or at the start of an actor call." |
for | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Executes the body with the symbol `sym` bound to each value of the given sequence. Returns a vector of results." |
- | - | "Subtracts numerical arguments from the first argument. Negates a single argument." |
*controller* | *controller* | "Returns the controller of the current account." |
*registry* | #9 | "Address of the Convex registry actor." |
min | min | "Returns the numerical minimum of the given values. If two or more values are equal to the minimum, the first is returned." |
< | < | "Tests if numeric arguments are in strict increasing order. Reads as 'less-than'." |
bit-or | bit-or | "Returns the bitwise OR of two Long values." |
get-peer-stake | get-peer-stake | "Gets the peer stake for a specific peer." |
*peer* | *peer* | "Returns the peer responsible for the current Block, or null if outside a block (e.g. query)." |
*parent* | *parent* | "Returns the parent of the current account. Determines the default location for symbolic lookup." |
tailcall | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Perform a tail call to a function without consuming additional stack depth." "Assumes tail position: rest of the current function, if any, will not be executed."] |
set! | set! | ["Sets a binding to the given value." "A local change will be be visible until the scope leaves the current binding form (e.g. `let` binding, function body or recur)." "Returns the value assigned to the local binding if successful."] |
query | query | "Runs forms in query mode. When returning a result, any State changes will be rolled back as if nothing happened." |
coin-supply | (fn ([] (loop [i 1 supply 1000000000000000000 ] (cond (#8/>= %0 8) %1 (#8/recur (#8/inc %0) (#8/- %1 (#8/balance (#8/address %0)))))))) | "Gets the total supply of Convex Coins." |
lookup | lookup | "Looks up the value of a Symbol in the current execution environment, or the Account of the given Address if specified." |
*juice-limit* | *juice-limit* | ["Returns the limit of execution juice available." "Juice is required for every CVM operation executed, and the transaction will fail immediately with a `:JUICE` error if an attempt is made to consume juice beyond this value."] |
def | def | ["Creates a definition in the current environment. This value will persist in the environment owned by the current account." "The name argument must be a symbol, or a Symbol wrapped in a syntax object with optional metadata."] |
halt | halt | ["Completes execution in the current context with the specified result, or null if not provided. Does not roll back any state changes made." "If the currently executing context is an actor, the result will be used as the return value from the actor call."] |
rem | rem | "Returns the remainder of a numerator divided by a divisor, consistent with division performed by `quot`. The remainder will therefore have the same sign as the numerator." |
transfer-memory | transfer-memory | "Transfers the specified amount of memory allowance to the target `address`. Returns the amount transferred if successful." |
vec | vec | "Coerces the argument to a vector. Arguement must be coercible to a sequential data structure." |
intersection | intersection | "Computes the intersection of one or more sets. Nil is treated as an empty set." |
disj | disj | "Removes the specified key(s) from a set. `nil` is treated as the empty Set." |
exp | exp | "Returns `e` raised to the power of the given numerical argument." |
quasiquote* | (fn [form depth] (cond (#8/empty? %0) (#8/return nil) (#8/list? %0) (let [fst (#8/first %0) ] (cond (#8/= quasiquote %2) (cond (#8/!= 2 (#8/count %0)) (#8/fail :EXPAND "nested quasiquote requires 1 argument") (let [snd (#8/second %0) ev (#8/quasiquote* %3 (#8/inc %1)) ] (cond (#8/nil? %4) (#8/return nil) (#8/list list (quote quasiquote) %4)))) (#8/= unquote %2) (cond (#8/!= 2 (#8/count %0)) (#8/fail :EXPAND "unquote requires 1 argument") (let [snd (#8/second %0) ] (cond (#8/> %1 1) (let [ev (#8/quasiquote* %3 (#8/dec %1)) ] (cond (#8/nil? %4) (#8/return nil)) (#8/list list (quote unquote) %4)) (#8/nil? %3) (#8/compile nil) %3))) (let [es (#8/qq-seq %0 %1) ] (cond (#8/nil? %3) (#8/return nil)) (#8/cons list %3)))) (#8/vector? %0) (let [es (#8/qq-seq (#8/vec %0) %1) ] (cond (#8/nil? %2) (#8/return nil)) (#8/vec %2)) (#8/set? %0) (let [es (#8/qq-seq (#8/vec %0) %1) ] (cond (#8/nil? %2) (#8/return nil) (#8/cons list (quote hash-set) %2))) (#8/map? %0) (let [es (#8/qq-seq (#8/apply #8/concat (#8/vec %0)) %1) ] (cond (#8/nil? %2) (#8/return nil) (#8/cons list (quote hash-map) %2))) nil)) | nil |
vector? | vector? | "Returns true if the argument is a vector, false otherwise." |
nth | nth | ["Gets the nth element of a Countable data structure." "The index must be a valid integer between 0 (inclusive) and the count of the collection (exclusive)."] |
get-stake | get-stake | "Gets the delgated stake for an account on a specific peer." |
set | set | "Coerces any data structure to a `Set`." |
*key* | *key* | "Returns the public key for this account. Returns nil in the case of an actor since actors are accounts without keys." |
countable? | countable? | "Returns true if the argument is countable." |
empty | empty | "Returns an empty collection of the same type as the argument. `(empty nil)` returns nil." |
double | double | "Casts any numerical value to a `Double`." |
hash-map | hash-map | "Constructs a map with the given keys and values. If a key is repeated, the last value will overwrite previous ones." |
set-peer-stake | set-peer-stake | "Sets the peer stake. Stake must be a `long`. Peer must exist, with a public account key." |
if | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["If `test` expression evaluates to a truthy value (anything but false or nil), executes `expr-true`. Otherwise, executes `expr-false`." "For a more general conditional expression that can handle multiple branches, see `cond.` Also see `when`."] |
defn | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Defines a function in the current environment." |
keccak256 | keccak256 | "Calculates the 32-byte Keccak-256 cryptographic hash of a `blob` or an `address` (which is a specialized type of `blob`). Returns a 32-byte `blob`." |
long? | long? | "Returnes `true` if the argument is a value of Long type, `false` otherwise." |
identity | (fn [x & _] %0) | "An identity function which returns its first argument unchanged." |
signum | signum | "Returns the signum of a numeric value, defined to be -1, 0 or 1." |
div | div | "Returns the integer value of a numerator divided by a divisor. Performs Euclidian division (i.e. non-negative remainder)." |
and | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Executes expressions in sequence, returning the first falsey value (false or nil), or the last value otherwise." "Does not evaluate later expressions, so can be used to short circuit execution." "Returns true with no expressions present."] |
keys | keys | "Returns a Vector of keys in the given Map, in the map defined order. Also see `values`." |
<= | <= | "Tests if numeric arguments are in increasing order. Reads as 'less-than-or-equal'." |
when-let | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Evaluates a binding expression. If truthy, executes the body with the symbol bound to the result." "Returns nil otherwise."] |
call | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | ["Calls a function in another account, optionally offering coins which the account may receive using `accept`." "Must refer to a callable function defined in the actor, called with appropriate arguments."] |
set-key | set-key | ["Sets the public key (32-byte blob) for the current account. May set to `nil` to turn this account into an actor and disable future external transactions." "WARNING: You may lose access to the account if you do not have access to the associated private key."] |
hash | hash | "Calculates the 32-byte SHA3-256 cryptographic hash of a `blob` or an `address` (which is a specialized type of `blob`). Returns a 32-byte `blob`." |
abs | abs | "Computes the absolute value of a numerical argument. Supports `double` and `long` results." |
let | let | "Binds local variables according to symbol-expression pairs in a binding vectors, then execute following expressions in an implicit do block." |
filter | (fn [pred coll] (#8/reduce (fn [acc e] (cond (%0 %3) (#8/conj %2 %3) %2)) (#8/empty %1) (cond (#8/list? %1) (#8/reverse %1) %1))) | ["Filters a collection by applying the given predicate to each element." "Each element is included in the new collection if and only if the predicate returns a truthy value (anything but false or nil)."] |
bit-not | bit-not | "Returns the bitwise NOT of a Long value." |
*nop* | *nop* | "Does nothing." |
callable? | callable? | "Returns true if the target can be called. If symbol is provided, checks that this symbol references a callable function in the specified account. See `call`." |
dissoc | dissoc | "Removes entries with the specified key(s) from a Map (including Indexes). `nil` is treated as the empty Map." |
bit-xor | bit-xor | "Returns the bitwise XOR of two Long values." |
*lang* | nil | ["Advanced feature. Language front-end function." "If set to a function via `def`, will be called with the code for each transaction instead of delegating to normal `eval` behavior." "Pre-compiled operations (see `compile`) bypass this language setting."] |
*address* | *address* | "Returns the address of the current account (user address in regular transaction, actor address in actor calls)." |
defined? | (fn ([sym] (do (cond (#8/symbol? %0) *result* (#8/fail :CAST "defined? requires a Symbol")) (#8/boolean (#8/lookup-meta %0)))) ([addr sym] (do (cond (#8/symbol? %1) *result* (#8/fail :CAST "defined? requires a Symbol")) (#8/boolean (#8/lookup-meta %0 %1))))) | "Returns true if the given symbol name is defined in the current or specified account environment, false otherwise." |
declare | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Declares symbols in the current environment. Used for forward declarations." |
assoc-in | assoc-in | "Associates a value into a nested associative data structure, as if using `assoc` at each level." |
bit-and | bit-and | "Returns the bitwise AND of two Long values." |
qq-seq | (fn [ss depth] (let [n (#8/count %0) ] (loop [i 0 found false ss %0 ] (cond (#8/< %3 %2) (let [v (#8/nth %5 %3) e (#8/quasiquote* %6 %1) ] (cond (#8/nil? %7) (set! %5 (#8/assoc %5 %3 (#8/list quote %6))) (do (set! %4 true) (set! %5 (#8/assoc %5 %3 %7)))) (#8/recur (#8/inc %3) %4 %5)) (cond %4 %5 nil))))) | nil |
schedule* | schedule* | "Schedules a Op for future execution under this account. Op will not be executed until the specified timestamp. `compile` may be used to produce an Op from a normal code form." |
do | do | "Executes multiple expressions sequentially, and returns the value of the final expression." |
char | char | "Casts a value to a Character. Treats integers as Unicode code points. Treats blob-like values as UTF-8 strings." |
keyword? | keyword? | "Returns `true` if and only if the argument is a Keyword." |
blob? | blob? | "Returns true if and only if the argument is a Blob." |
scope | (fn [a] (cond (#8/address? %0) nil (#8/not (#8/callable? %0)) nil (#8/nth %0 1))) | "Gets the scope from a callable value, or nil if undefined" |
str? | str? | "Returns true if the argument is a string, false otherwise." |
when | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Executes body expressions in an implicit `do` block if and only if the `test` expression evaluates to a truthy value (anything but false or nil)." |
doc | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Returns the documentation for a given definition." |
if-let | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Similar to `if`, but the test expression in bound to a symbol so that it can be accessed in the `expr-true` branch." |
qq* | (fn [form depth] (let [qf (#8/quasiquote* %0 %1) ] (cond %2 %2 (#8/list quote %0)))) | nil |
meta | meta | "Returns metadata for a Syntax Object. Returns `nil` if the argument is not a syntax object." |
map? | map? | "Returns true if and only if the argument is a Map." |
reduced | reduced | "Returns immediately from the enclosing `reduce` function, providing the given value as the result of the whole `reduce` operation. This can be used to terminate a reduction early, saving transaction costs." |
get | get | ["Gets an element from a collection at the specified index value. Works on all collection types including maps, sets and sequences. Nil is treated as an empty collection." "If the index is not present, returns `not-found` value (nil by default)."] |
undef | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Opposite of `def`. Undefines a symbol, removing the mapping from the current environment if it exists." |
get-in | get-in | "Gets an element by successively looking up keys in nested collections according to the logic of `get`. If any lookup does not find the appropriate key, will return `not-found` (nil by default)." |
set-in! | (fn [x e] (#8/tailcall* %2 (#8/apply %0 (#8/next %1)) %2)) | "Sets a value within a nested associative structure, combining behaviour of set! and assoc-in." |
accept | accept | ["Used during a `call`, accepts offered coins up to the amount of `*offer*` from `*caller*`. Returns the amount accepted if successful." "Amount must cast to `Long`. If successful, the amount will be added immediately to the `*balance*` of the current `*address*`." "This is the recommended way of transferring balance between actors, as it requires a positive action to confirm receipt."] |
next | next | "Returns the elements of a sequential data structure after the first element, or `nil` if no more elements remain." |
union | union | "Computes the union of zero or more sets. Nil is treated as an empty set when used as an input, but any result will always be a valid non-nil Set." |
set-peer-data | set-peer-data | "Sets metadata on an existing peer. Metadata must be a Map." |
keyword | keyword | "Casts the argument to a Keyword: must be a name between 1 and 128 UTF-8 bytes." |
ceil | ceil | "Computes the mathematical ceiling (rounding up towards positive infinity) for a numerical argument. Uses double precision mathematics." |
cond | cond | ["Performs conditional tests on successive (test, result) pairs, computing the result for the first test that succeeds." "Result expressions that are not used and any test expressions after the first success will not be executed." "If no test succeeds, a final expression may be added as a fallback. If no fallback value is available, nil will be returned."] |
set-controller | set-controller | ["Sets the controller for the current account." "Controller account is granted powerful access privileges including the ability to run `eval-as`. Setting to nil disable such control (default value)."] |
comp | (fn ([f] %0) ([f g] (fn [& args] (%0 (#8/apply %1 %2)))) ([f g h] (fn [& args] (%0 (%1 (#8/apply %2 %3))))) ([f g h & more] (#8/apply #8/comp (fn [x] (%0 (%1 (%2 %4)))) %3))) | ["Returns a function that is the composition of the given functions." "Functions are executed left to right, The righmost function may take a variable number of arguments." "The result of each function is passed to the next one."] |