Standard library¶
%¶
Type
(-> Number Number Number)
Description
Modulo operator. It returns remainder of dividing first argument by second argument
Parameters
Number - Dividend
Number - Divisor
Returns
Number Remainder
(@kind atom)¶
Type
DocKindAtom
Description
Used for documentation purposes. Shows type of entity to be documented. (@kind atom) in this case## (@kind function) Type
DocKindFunction
Description
Used for documentation purposes. Shows type of entity to be documented. (@kind function) in this case## * Type
(-> Number Number Number)
Description
Multiplies two numbers
Parameters
Number - Multiplier
Number - Multiplicand
Returns
Number Product
+¶
Type
(-> Number Number Number)
Description
Sums two numbers
Parameters
Number - Addend
Number - Augend
Returns
Number Sum
-¶
Type
(-> Number Number Number)
Description
Subtracts second argument from first one
Parameters
Number - Minuend
Number - Deductible
Returns
Number Difference
/¶
Type
(-> Number Number Number)
Description
Divides first argument by second one
Parameters
Number - Dividend
Number - Divisor
Returns
Number Fraction
<¶
Type
(-> Number Number Bool)
Description
Less than. Checks if first argument is less than second one
Parameters
Number - First number
Number - Second number
Returns
Bool True if first argument is less than second, False - otherwise
<=¶
Type
(-> Number Number Bool)
Description
Less than or equal. Checks if first argument is less than or equal to second one
Parameters
Number - First number
Number - Second number
Returns
Bool True if first argument is less than or equal to second, False - otherwise
=¶
Type
(-> $t#977985 $t#977985 %Undefined%)
Description
A symbol used to define reduction rules for expressions.
Parameters
$type#982965 - Pattern to be matched against expression to be reduced
$t#977985 - Result of reduction or transformation of the first pattern
Returns
%Undefined% Not reduced itself unless custom equalities over equalities are added
==¶
Type
(-> $t#44664 $t#44664 Bool)
Description
Checks equality for two arguments of the same type
Parameters
$t#44664 - First argument
$t#44664 - Second argument
Returns
Bool Returns True if two arguments are equal, False - otherwise. If arguments are of different type function returns Error currently
=alpha¶
Type
(-> Atom Atom Bool)
Description
Checks alpha equality of two expressions
Parameters
Atom - First expression
Atom - Second expression
Returns
Bool True if both expressions are alpha equal, False - otherwise
>¶
Type
(-> Number Number Bool)
Description
Greater than. Checks if first argument is greater than second one
Parameters
Number - First number
Number - Second number
Returns
Bool True if first argument is greater than second, False - otherwise
>=¶
Type
(-> Number Number Bool)
Description
Greater than or equal. Checks if first argument is greater than or equal to second one
Parameters
Number - First number
Number - Second number
Returns
Bool True if first argument is greater than or equal to second, False - otherwise
@desc¶
Type
(-> String DocDescription)
Description
Used for documentation purposes. Description of function starts with @desc as a part of @doc
Parameters
String - String containing function description
Returns
DocDescription Function description
@doc¶
Type
(-> Atom DocDescription DocParameters DocReturnInformal DocInformal)
Description
Used for documentation purposes. Function documentation starts with @doc
Parameters
Atom - Function name
DocDescription - Function description. Starts with @desc
DocParameters - (Optional) parameters description starting with @params which should contain one or more @param symbols
DocReturnInformal - (Optional) description of what function will return. Starts with @return
Returns
DocInformal Function documentation using @doc-formal
@doc-formal¶
Type
(-> DocItem DocKindFunction DocType DocDescription DocParameters DocReturn DocFormal)
Description
Used for documentation purposes. get-doc returns documentation starting with @doc-formal symbol. @doc-formal contains 6 or 4 parameters depending on the entity being described (functions being described using 6 parameters, atoms - 4 parameters)
Parameters
DocItem - Function/Atom name for which documentation is to be displayed. Format (@item name)
DocKindFunction - Contains (@kind function) or (@kind atom) depends on entity which documentation is displayed
DocType - Contains type notation of function/atom
DocDescription - Function/atom description
DocParameters - (Functions only). Description of function parameters
DocReturn - (Functions only). Description of function's return value
Returns
DocFormal Expression containing full documentation on function
@item¶
Type
(-> Atom DocItem)
Description
Used for documentation purposes. Converts atom/function's name to DocItem
Parameters
Atom - Atom/Function name to be documented
Returns
DocItem (@item Atom) entity
@param¶
Type
(-> DocType DocDescription DocParameter)
Description
Used for documentation purposes. Description of function parameter starts with @param as a part of @params which is a part of @doc
Parameters
DocType - String containing parameter description
Returns
DocDescription Parameter description
@param¶
Type
(-> String DocParameterInformal)
Description
Used for documentation purposes. Description of function parameter starts with @param as a part of @params which is a part of @doc
Parameters
String - String containing parameter description
Returns
DocParameterInformal Parameter description
@params¶
Type
(-> Expression DocParameters)
Description
Used for function documentation purposes. Contains several @param entities with description of each @param
Parameters
Expression - Several (@param ...) entities
Returns
DocParameters DocParameters containing description of all parameters of function in form of (@params ((@param ...) (@param ...) ...))
@return¶
Type
(-> DocType DocDescription DocReturn)
Description
Used for documentation purposes. Description of function return value starts with @return as a part of @doc
Parameters
DocType - String containing return value description
Returns
DocDescription Return value description
@return¶
Type
(-> String DocReturnInformal)
Description
Used for documentation purposes. Description of function return value starts with @return as a part of @doc
Parameters
String - String containing return value description
Returns
DocReturnInformal Return value description
@type¶
Type
(-> Type DocType)
Description
Used for documentation purposes. Converts atom/function's type to DocType
Parameters
Type - Atom/Function type to be documented
Returns
DocType (@type Type) entity
BadArgType¶
Type
(-> Number Type Type ErrorDescription)
Description
BadArgType error constructor
Parameters
Number - Index of atom in expression which produced this error
Type - Expected type
Type - Actual type
Returns
ErrorDescription Instance of the BadArgType error atom
BadType¶
Type
(-> Type Type ErrorDescription)
Description
BadType error constructor
Parameters
Type - Expected type
Type - Actual type
Returns
ErrorDescription Instance of the BadType error atom
Error¶
Type
(-> Atom Atom ErrorType)
Description
Error constructor
Parameters
Atom - Atom which contains error
Atom - Error message, can be one of the reserved symbols: BadType, IncorrectNumberOfArguments
Returns
ErrorType Instance of the error atom
ErrorType¶
Type
Type
Description
Type of the atom which contains error## SpaceType Type
Type
Description
Type of the atom which contains space## _collapse-add-next-atom-from-collapse-bind-result Type
(-> Expression Expression Atom)
Description
Adds atom from collapse-bind result to the passed list
Parameters
Expression - List to add an atom into
Expression - collapse-bind result to extract atom from, should be a pair of atom and bindings
Returns
Atom List with new atom as a head
abs-math¶
Type
(-> Number Number)
Description
Returns absolute value of input number (first argument)
Parameters
Number - Input number
Returns
Number Absolute value
acos-math¶
Type
(-> Number Number)
Description
Returns result of the arccosine function for an input value (first argument)
Parameters
Number - Float number
Returns
Number Result of the arccosine function
add-atom¶
Type
(-> SpaceType Atom (->))
Description
Adds atom into the atomspace without reducing it
Parameters
SpaceType - Atomspace to add atom into
Atom - Atom to add
Returns
(->) Unit atom
add-atoms¶
Type
(-> SpaceType Expression (->))
Description
Function takes space and expression and adds atoms in Expression into given space without reducing them
Parameters
SpaceType - Space
Expression - Expression
Returns
(->) Unit atom
add-reduct¶
Type
(-> SpaceType %Undefined% (->))
Description
Reduces atom (second argument) and adds it into the atomspace (first argument)
Parameters
SpaceType - Atomspace to add atom into
%Undefined% - Atom to add
Returns
(->) Unit atom
add-reducts¶
Type
(-> SpaceType %Undefined% (->))
Description
Function takes space and expression, evaluates atoms in it and adds them into given space
Parameters
SpaceType - Space
%Undefined% - Expression
Returns
(->) Unit atom
and¶
Type
(-> Bool Bool Bool)
Description
Logical conjunction of two arguments
Parameters
Bool - First argument
Bool - Second argument
Returns
Bool Returns True if both arguments are True, False - otherwise
asin-math¶
Type
(-> Number Number)
Description
Returns result of the arcsine function for an input value (first argument)
Parameters
Number - Float number
Returns
Number Result of the arcsine function
assertAlphaEqual¶
Type
(-> Atom Atom (->))
Description
Compares (sets of) results of evaluation of two expressions using alpha equality
Parameters
Atom - First expression
Atom - Second expression
Returns
(->) Unit atom if both expressions after evaluation are alpha equal, error - otherwise
assertAlphaEqualMsg¶
Type
(-> Atom Atom Atom (->))
Description
Compares (sets of) results of evaluation of two expressions using alpha equality
Parameters
Atom - First expression
Atom - Second expression
Atom - Message to return on assert failure
Returns
(->) Unit atom if both expressions after evaluation are alpha equal, input message - otherwise
assertAlphaEqualToResult¶
Type
(-> Atom Atom (->))
Description
Same as assertAlphaEqual but it doesn't evaluate second argument. Second argument is considered as a set of values of the first argument's evaluation
Parameters
Atom - First expression (it will be evaluated)
Atom - Second expression (it won't be evaluated)
Returns
(->) Unit atom if both expressions after evaluation of the first argument are alpha equal, error - otherwise
assertAlphaEqualToResultMsg¶
Type
(-> Atom Atom Atom (->))
Description
Same as assertAlphaEqualMsg but it doesn't evaluate second argument. Second argument is considered as a set of values of the first argument's evaluation
Parameters
Atom - First expression (it will be evaluated)
Atom - Second expression (it won't be evaluated)
Atom - Message to return on assert failure
Returns
(->) Unit atom if both expressions after evaluation of the first argument are alpha equal, input message - otherwise
assertEqual¶
Type
(-> Atom Atom (->))
Description
Compares (sets of) results of evaluation of two expressions
Parameters
Atom - First expression
Atom - Second expression
Returns
(->) Unit atom if both expressions after evaluation are equal, error - otherwise
assertEqualMsg¶
Type
(-> Atom Atom Atom (->))
Description
Compares (sets of) results of evaluation of two expressions
Parameters
Atom - First expression
Atom - Second expression
Atom - Message to return on assert failure
Returns
(->) Unit atom if both expressions after evaluation are equal, input message - otherwise
assertEqualToResult¶
Type
(-> Atom Atom (->))
Description
Same as assertEqual but it doesn't evaluate second argument. Second argument is considered as a set of values of the first argument's evaluation
Parameters
Atom - First expression (it will be evaluated)
Atom - Second expression containing the expected evaluation results (it won't be evaluated)
Returns
(->) Unit atom if both expressions after evaluation of the first argument are equal, error - otherwise
assertEqualToResultMsg¶
Type
(-> Atom Atom Atom (->))
Description
Same as assertEqualMsg but it doesn't evaluate second argument. Second argument is considered as a set of values of the first argument's evaluation
Parameters
Atom - First expression (it will be evaluated)
Atom - Second expression containing the expected evaluation results (it won't be evaluated)
Atom - Message to return on assert failure
Returns
(->) Unit atom if both expressions after evaluation of the first argument are equal, input message - otherwise
assertIncludes¶
Type
(-> Atom Expression (->))
Description
Checks if the content in the second argument is included in the results of the first argument's evaluation
Parameters
Atom - First expression
Expression - Second expression
Returns
(->) Unit atom if the second argument is included in the results of the first argument's evaluation, error - otherwise
atan-math¶
Type
(-> Number Number)
Description
Returns result of the arctangent function for an input value (first argument)
Parameters
Number - Float number
Returns
Number Result of the tangent function
atom-subst¶
Type
(-> Atom Variable Atom Atom)
Description
Substitutes variable passed as a second argument in the third argument by the first argument
Parameters
Atom - Value to use for replacement
Variable - Variable to replace
Atom - Template to replace variable by the value
Returns
Atom Template with substituted variable
bind!¶
Type
(-> Symbol %Undefined% (->))
Description
Registers a new token which is replaced with an atom during the parsing of the rest of the program
Parameters
Symbol - Token name
%Undefined% - Atom, which is associated with the token after reduction
Returns
(->) Unit atom
capture¶
Type
(-> Atom Atom)
Description
Wraps an atom and capture the current space
Parameters
Atom - Function name which space need to be captured
Returns
Atom Function
car-atom¶
Type
(-> Expression %Undefined%)
Description
Extracts the first atom of an expression as a tuple
Parameters
Expression - Expression
Returns
%Undefined% First atom of an expression
case¶
Type
(-> Atom Expression %Undefined%)
Description
Subsequently tests multiple pattern-matching conditions (second argument) for the given value (first argument)
Parameters
Atom - Atom (it will be evaluated)
Expression - Tuple of pairs mapping condition patterns to results
Returns
%Undefined% Result of evaluating of Atom bound to met condition
cdr-atom¶
Type
(-> Expression Expression)
Description
Extracts the tail of an expression (all except first atom)
Parameters
Expression - Expression
Returns
Expression Tail of an expression
ceil-math¶
Type
(-> Number Number)
Description
Returns the smallest integer greater than or equal to the input value (first argument)
Parameters
Number - Float value
Returns
Number Integer value greater than or equal to the input
chain¶
Type
(-> Atom Variable Atom %Undefined%)
Description
Evaluates first argument, binds it to the variable (second argument) and then evaluates third argument which contains (or not) mentioned variable
Parameters
Atom - Atom to be evaluated
Variable - Variable
Atom - Atom which will be evaluated at the end
Returns
%Undefined% Result of evaluating third input argument
change-state!¶
Type
(-> (StateMonad $tcso#302437) $tcso#302437 (StateMonad $tcso#302437))
Description
Changes input state's wrapped atom to another value (second argument). E.g. (change-state! (State 5) 6) -> (State 6)
Parameters
(StateMonad $tcso#302437) - State created by new-state function
$type#308370 - Atom which will replace wrapped atom in the input state
Returns
(StateMonad $tcso#302437) State with replaced wrapped atom
collapse¶
Type
(-> Atom Atom)
Description
Converts a nondeterministic result into a tuple
Parameters
Atom - Atom which will be evaluated
Returns
Atom Tuple
collapse-bind¶
Type
(-> Atom Expression)
Description
Evaluates minimal MeTTa operation (first argument) and returns an expression which contains all alternative evaluations in a form (Atom Bindings). Bindings are represented in a form of a grounded atom.
Parameters
Atom - Minimal MeTTa operation to be evaluated
Returns
Expression All alternative evaluations
cons-atom¶
Type
(-> Atom Expression Atom)
Description
Constructs an expression using two arguments
Parameters
Atom - Head of an expression
Expression - Tail of an expression
Returns
Atom New expression consists of two input arguments
context-space¶
Type
(-> SpaceType)
Description
Returns the space which is used as a context space in atom evaluation
Parameters
Returns
SpaceType Context space
cos-math¶
Type
(-> Number Number)
Description
Returns result of the cosine function for an input value in radians (first argument)
Parameters
Number - Angle in radians
Returns
Number Result of the cosine function
decons-atom¶
Type
(-> Expression Atom)
Description
Works as a reverse to cons-atom function. It gets Expression as an input and returns it splitted to head and tail, e.g. (decons-atom (Cons X Nil)) -> (Cons (X Nil))
Parameters
Expression - Expression
Returns
Atom Deconsed expression
empty¶
Type
%Undefined%
Description
Cuts evaluation of the non-deterministic branch and removes it from the result
Parameters
Returns
%Undefined% Nothing
eval¶
Type
(-> Atom Atom)
Description
Evaluates input atom, makes one step of the evaluation
Parameters
Atom - Atom to be evaluated, can be reduced via equality expression (= ...) or by calling a grounded function
Returns
Atom Result of evaluation
evalc¶
Type
(-> Atom SpaceType Atom)
Description
Evaluates input atom, makes one step of the evaluation
Parameters
Atom - Atom to be evaluated, can be reduced via equality expression (= ...) or by calling a grounded function
SpaceType - Space to evaluate atom in its context
Returns
Atom Result of evaluation
filter-atom¶
Type
(-> Expression Variable Atom Expression)
Description
Function takes list of atoms (first argument), variable (second argument) and filter predicate (third argument) and returns list with items which passed filter. E.g. (filter-atom (1 2 3 4) $v (eval (> $v 2))) will give (3 4)
Parameters
Expression - List of atoms
Variable - Variable
Atom - Filter predicate
Returns
Expression Filtered list
first-from-pair¶
Type
%Undefined%
Description
Gets a pair as a first argument and returns first atom from pair
Parameters
%Undefined% - Pair
Returns
%Undefined% First atom from a pair
floor-math¶
Type
(-> Number Number)
Description
Returns the smallest integer less than or equal to the input value (first argument)
Parameters
Number - Float value
Returns
Number Integer value less than or equal to the input
foldl-atom¶
Type
(-> Expression Atom Variable Variable Atom %Undefined%)
Description
Function takes list of values (first argument), initial value (second argument) and operation (fifth argument) and applies it consequently to the list of values, using init value as a start. It also takes two variables (third and fourth argument) to use them inside
Parameters
Expression - List of values
Atom - Init value
Variable - Variable
Variable - Variable
Atom - Operation
Returns
%Undefined% Result of applying operation to the list of values
for-each-in-atom¶
Type
(-> Expression Atom (->))
Description
Applies function passed as a second argument to each atom inside first argument
Parameters
Expression - Expression to each atom in which function will be applied
Atom - Function to apply
Returns
(->) Unit atom
format-args¶
Type
(-> String Expression String)
Description
Fills {} symbols in the input expression with atoms from the second expression. E.g. (format-args (Probability of {} is {}%) (head 50)) gives [(Probability of head is 50%)]. Atoms in the second input value could be variables
Parameters
String - Expression with {} symbols to be replaced
Expression - Atoms to be placed inside expression instead of {}
Returns
String Expression with replaced {} with atoms
function¶
Type
(-> Atom Atom)
Description
Evaluates the argument until it becomes (return
Parameters
Atom - Atom to be evaluated
Returns
Atom Result of atom's evaluation
get-atoms¶
Type
(-> SpaceType Atom)
Description
Shows all atoms in the input Atomspace
Parameters
SpaceType - Reference to the space
Returns
Atom List of all atoms in the input space
get-doc¶
Type
(-> SpaceType Atom %Undefined%)
Description
Returns documentation for the given Atom/Function
Parameters
SpaceType - Atomspace where documentation should be searched
Atom - Atom/Function name for which documentation is needed
Returns
%Undefined% Documentation for the given atom/function
get-doc-atom¶
Type
(-> SpaceType Atom %Undefined%)
Description
Function used by get-doc (in case of input type Expression) and get-doc-single-atom (in case input value is not a function) to get documentation on input value
Parameters
SpaceType - Atomspace where documentation should be searched
Atom - Atom's name to get documentation for
Returns
%Undefined% Documentation on input Atom
get-doc-function¶
Type
(-> SpaceType Atom Type %Undefined%)
Description
Function used by get-doc-single-atom to get documentation on a function. It returns documentation on a function if it exists or default documentation with no description otherwise
Parameters
SpaceType - Atomspace where documentation should be searched
Atom - Function name for which documentation is needed
Type - Type notation for this function
Returns
%Undefined% Documentation for the given function
get-doc-params¶
Type
(-> Expression Atom Expression (Expression Atom))
Description
Function used by get-doc-function to get function's parameters documentation (including return value)
Parameters
Expression - List of parameters in form of ((@param Description) (@param Description)...)
Atom - Return value's description in form of (@return Description)
Expression - Type notation without -> starting symbol e.g. (Atom Atom %Undefined%)
Returns
(Expression Atom) United list of params and return value each augmented with its type. E.g. (((@param (@type Atom) (@desc Description)) (@param (@type Atom) (@desc Description2))) (@return (@type Atom) (@desc Description)))
get-doc-single-atom¶
Type
(-> SpaceType Atom %Undefined%)
Description
Function used by get-doc to get documentation on either function or atom. It checks if input name is the name of function or atom and calls correspondent function
Parameters
SpaceType - Atomspace where documentation should be searched
Atom - Atom/Function name for which documentation is needed
Returns
%Undefined% Documentation for the given atom/function
get-metatype¶
Type
(-> Atom Atom)
Description
Returns metatype of the input atom
Parameters
Atom - Atom to get metatype for
Returns
Atom Metatype of input atom
get-state¶
Type
(-> (StateMonad $tgso#297417) $tgso#297417)
Description
Gets a state as an argument and returns its wrapped atom. E.g. (get-state (State 5)) -> 5
Parameters
(StateMonad $ret-type#296805) - State
Returns
$tgso#297417 Atom wrapped by state
get-type¶
Type
(-> Atom %Undefined%)
Description
Returns type notation of input atom
Parameters
Atom - Atom to get type for
Returns
%Undefined% Type notation or %Undefined% if there is no type for input Atom
get-type-space¶
Type
(-> SpaceType Atom Atom)
Description
Returns type notation of input Atom (second argument) relative to a specified atomspace (first argument)
Parameters
SpaceType - Atomspace where type notation for input atom will be searched
Atom - Atom to get type for
Returns
Atom Type notation or %Undefined% if there is no type for input Atom in provided atomspace
git-module!¶
Type
(-> Atom (->))
Description
Provides access to module in a remote git repo, from within MeTTa code. Similar to register-module!, this op will bypass the catalog search
Parameters
Atom - URL to github repo
Returns
(->) Unit atom
help!¶
Type
(-> Atom (->))
Description
Function prints documentation for the input atom. Without parameters prints the list of the stdlib functions.
Parameters
Atom - Input to get documentation for
Returns
(->) Unit atom
help-param!¶
Type
(-> Atom (->))
Description
Function used by function help! to output parameters using println!
Parameters
Atom - Parameters list
Returns
(->) Unit atom
id¶
Type
(-> $ret-type#768644 $ret-type#768644)
Description
Returns its argument
Parameters
$t#769267 - Input argument
Returns
$t#769267 Input argument
if¶
Type
(-> Bool Atom Atom $t#628540)
Description
Replace itself by one of the arguments depending on condition.
Parameters
Bool - Boolean condition
Atom - Result when condition is True
Atom - Result when condition is False
Returns
$ret-type#627917 Second or third argument
if-decons-expr¶
Type
(-> Expression Variable Variable Atom Atom %Undefined%)
Description
Checks if first argument is non empty expression. If so gets tail and head from the first argument and returns forth argument using head and tail values. Returns fifth argument otherwise.
Parameters
Expression - Expression to be deconstructed
Variable - Head variable
Variable - Tail variable
Atom - Template to return if first argument is a non-empty expression
Atom - Default value to return otherwise
Returns
%Undefined% Either template with head and tail replaced by values or default value
if-equal¶
Type
(-> Atom Atom Atom Atom %Undefined%)
Description
Checks if first two arguments are equal and evaluates third argument if equal, fourth argument - otherwise
Parameters
Atom - First argument
Atom - Second argument
Atom - Atom to be evaluated if arguments are equal
Atom - Atom to be evaluated if arguments are not equal
Returns
%Undefined% Evaluated third or fourth argument
if-error¶
Type
(-> Atom Atom Atom %Undefined%)
Description
Checks if first argument is an error atom. Returns second argument if so or third argument otherwise.
Parameters
Atom - Atom to be checked for the error
Atom - Value to return if first argument is an error
Atom - Value to return otherwise
Returns
%Undefined% Second or third argument
import!¶
Type
(-> Atom Atom (->))
Description
Imports module using its relative path (second argument), which could contain ':' as a path separation (e.g. !(import &module relative:path:to:module)) and binds it to the token (first argument) which will represent imported atomspace. If first argument is &self then everything will be imported to current atomspace)
Parameters
Atom - Symbol, which is turned into the token for accessing the imported module
Atom - Module name/relative path to module
Returns
(->) Unit atom
include¶
Type
(-> Atom %Undefined%)
Description
Works just like import! but with &self as a first argument. So everything from input file will be included in the current atomspace and evaluated
Parameters
Atom - Name of metta script to import
Returns
%Undefined% Unit atom
index-atom¶
Type
(-> Expression Number Atom)
Description
Returns atom from an expression (first argument) using index (second argument) or error if index is out of bounds
Parameters
Expression - Expression
Number - Index
Returns
Atom Atom from an expression in the place defined by index. Error if index is out of bounds
intersection¶
Type
(-> Atom Atom %Undefined%)
Description
Function takes two non-deterministic inputs (first and second argument) and returns their intersection. E.g. (intersection (superpose (a b c c)) (superpose (b c c c d))) -> [b, c, c]
Parameters
Atom - Non-deterministic set of values
Atom - Another non-deterministic set of values
Returns
%Undefined% Intersection of sets
intersection-atom¶
Type
(-> Expression Expression Atom)
Description
Function takes two tuples and returns their intersection. E.g. (intersection-atom (a b c c) (b c c c d)) -> (b c c)
Parameters
Expression - List of values
Expression - List of values
Returns
Atom Intersection of sets
is-function¶
Type
(-> Type Bool)
Description
Function checks if input type is a function type
Parameters
Type - Type atom
Returns
Bool True if type is a function type, False - otherwise
isinf-math¶
Type
(-> Number Bool)
Description
Returns True if input value is positive or negative infinity. False - otherwise
Parameters
Number - Number
Returns
Bool True/False
isnan-math¶
Type
(-> Number Bool)
Description
Returns True if input value is NaN. False - otherwise
Parameters
Number - Number
Returns
Bool True/False
let¶
Type
(-> Atom %Undefined% Atom %Undefined%)
Description
Unify two first argument and apply result of the unification on third argument. Second argument is evaluated before unification.
Parameters
Atom - First atom to be unified
%Undefined% - Second atom to be unified
Atom - Expression which will be evaluated if two first arguments can be unified
Returns
%Undefined% Third argument or Empty
let*¶
Type
(-> Expression Atom %Undefined%)
Description
Same as let but inputs list of pairs of atoms to be unified. For example (let* ((\(v1 (+ 1 2)) (\)v2 (* 5 6))) (+ $v1 $v2))
Parameters
Expression - List of pairs, atoms in each pair to be unified
Atom - Expression which will be evaluated if each pair can be unified
Returns
%Undefined% Second argument or Empty
log-math¶
Type
(-> Number Number Number)
Description
Returns result of a logarithm function given base (first argument) and input number (second argument)
Parameters
Number - Base
Number - Input number
Returns
Number Result of log function
map-atom¶
Type
(-> Expression Variable Atom Expression)
Description
Function takes list of atoms (first argument), variable to be used inside (second variable) and an expression which will be evaluated for each atom in list (third argument). Expression should contain variable. So e.g. (map-atom (1 2 3 4) $v (eval (+ $v 1))) will give (2 3 4 5)
Parameters
Expression - List of atoms
Variable - Variable name
Atom - Template using variable
Returns
Expression Result of evaluating template for each atom in a list
match¶
Type
(-> SpaceType Atom Atom %Undefined%)
Description
Searches for all declared atoms corresponding to the given pattern (second argument) inside space (first argument) and returns the output template (third argument)
Parameters
SpaceType - Atomspace to search pattern
Atom - Pattern atom to be searched
Atom - Output template typically containing variables from the input pattern
Returns
%Undefined% If match was successfull it outputs template (third argument) with filled variables (if any were present in pattern) using matched pattern (second argument). Empty - otherwise
match-type-or¶
Type
%Undefined%
Description
Checks if two types (second and third arguments) can be unified and returns result of OR operation between first argument and type checking result
Parameters
%Undefined% - Boolean value
%Undefined% - First type
%Undefined% - Second type
Returns
%Undefined% True or False
match-types¶
Type
%Undefined%
Description
Checks if two types can be unified and returns third argument if so, fourth - otherwise
Parameters
%Undefined% - First type
%Undefined% - Second type
%Undefined% - Atom to be returned if types can be unified
%Undefined% - Atom to be returned if types cannot be unified
Returns
%Undefined% Third or fourth argument
max-atom¶
Type
(-> %Undefined% Number)
Description
Returns atom with max value in the expression (first argument). Only numbers allowed
Parameters
%Undefined% - Expression which contains atoms of Number type
Returns
Number Max value in the expression. Error if expression contains non-numeric value or is empty
metta¶
Type
(-> Atom Type SpaceType Atom)
Description
Run MeTTa interpreter on atom.
Parameters
Atom - Atom to be interpreted
Type - Type of input atom
SpaceType - Atomspace where intepretation should take place
Returns
Atom Result of interpretation
min-atom¶
Type
(-> %Undefined% Number)
Description
Returns atom with min value in the expression (first argument). Only numbers allowed
Parameters
%Undefined% - Expression which contains atoms of Number type
Returns
Number Min value in the expression. Error if expression contains non-numeric value or is empty
mod-space!¶
Type
(-> Atom SpaceType)
Description
Returns the space of the module (first argument) and tries to load the module if it is not loaded into the module system
Parameters
Atom - Module name
Returns
SpaceType Space name
module-space-no-deps¶
Type
(-> SpaceType SpaceType)
Description
Gets module space and returns the space without dependencies. It is useful when one need to search the module space itself not including imported modules.
Parameters
SpaceType - Module space
Returns
SpaceType Space without dependencies included
new-space¶
Type
(-> SpaceType)
Description
Creates new Atomspace which could be used further in the program as a separate from &self Atomspace
Parameters
Returns
SpaceType Reference to a new space
new-state¶
Type
(-> $t#309552 (StateMonad $t#309552))
Description
Creates a new state atom wrapping its argument
Parameters
$t#309552 - Atom to be wrapped
Returns
(StateMonad $t#309552) Returns (State $value) where $value is an argument to a new-state
noeval¶
Type
(-> Atom Atom)
Description
Returns its argument
Parameters
Atom - Input argument
Returns
Atom Input argument
nop¶
Type
%Undefined%
Description
Outputs unit atom
Parameters
Returns
%Undefined% Unit atom
noreduce-eq¶
Type
(-> Atom Atom Bool)
Description
Checks equality of two atoms without reducing them
Parameters
Atom - First atom
Atom - Second atom
Returns
Bool True if not reduced atoms are equal, False - otherwise
not¶
Type
(-> Bool Bool)
Description
Logical negation
Parameters
Bool - Argument
Returns
Bool Negates boolean input argument (False -> True, True -> False)
or¶
Type
(-> Bool Bool Bool)
Description
Logical disjunction of two arguments
Parameters
Bool - First argument
Bool - Second argument
Returns
Bool True if any of input arguments is True, False - otherwise
pow-math¶
Type
(-> Number Number Number)
Description
Takes base (first argument) and power (second argument) and returns result of a power function (base ^ power)
Parameters
Number - Base
Number - Power
Returns
Number Result of a power function
pragma!¶
Type
%Undefined%
Description
Changes global key's (first argument) value to a new one (second argument). Possible pragmas: (pragma! type-check auto) - check type of the atom before evaluation (pragma! interpreter bare-minimal) - use minimal MeTTa semantics when evaluating atom (pragma! max-stack-depth
Parameters
%Undefined% - Key's name
%Undefined% - New value
Returns
%Undefined% Unit atom
print-mods!¶
Type
(-> (->))
Description
Prints all modules with their correspondent spaces
Parameters
Returns
(->) Unit atom
println!¶
Type
(-> %Undefined% (->))
Description
Prints a line of text to the console
Parameters
%Undefined% - Expression/atom to be printed out
Returns
(->) Unit atom
quote¶
Type
(-> Atom Atom)
Description
Prevents atom from being reduced
Parameters
Atom - Atom
Returns
Atom Quoted atom
register-module!¶
Type
(-> Atom (->))
Description
Takes a file system path (first argument) and loads the module into the runner
Parameters
Atom - File system path
Returns
(->) Unit atom
remove-atom¶
Type
(-> SpaceType Atom (->))
Description
Removes atom from the input Atomspace
Parameters
SpaceType - Reference to the space from which the Atom needs to be removed
Atom - Atom to be removed
Returns
(->) Unit atom
return¶
Type
(-> $t#950102 $t#950102)
Description
Returns value from the (function ...) expression
Parameters
$type#953882 - Value to be returned
Returns
$t#950102 Passed argument
return-on-error¶
Type
(-> Atom Atom %Undefined%)
Description
Returns first argument if it is Empty or an error. Returns second argument otherwise.
Parameters
Atom - Previous evaluation result
Atom - Atom for further evaluation
Returns
%Undefined% Return previous result if it is an error or Empty or continue evaluation
round-math¶
Type
(-> Number Number)
Description
Returns the nearest integer to the input float value (first argument)
Parameters
Number - Float value
Returns
Number Nearest integer to the input
sealed¶
Type
(-> Expression Atom Atom)
Description
Replaces all occurrences of any var inside atom (second argument) by unique variable, except list of variables to ignore (first argument). Can be used to create a locally scoped variables
Parameters
Expression - Variable list to ignore e.g. ($x $y)
Atom - Atom which uses those variables
Returns
Atom Second argument but with variables being replaced with unique variables
sin-math¶
Type
(-> Number Number)
Description
Returns result of the sine function for an input value in radians (first argument)
Parameters
Number - Angle in radians
Returns
Number Result of the sine function
size-atom¶
Type
(-> Expression Number)
Description
Returns size of an expression (first argument)
Parameters
Expression - Expression
Returns
Number Size of an expression
sort-strings¶
Type
(-> Expression Expression)
Description
Sorts expression which contains strings in alphabet order
Parameters
Expression - List of strings
Returns
Expression Sorted list of strings
sqrt-math¶
Type
(-> Number Number)
Description
Returns square root for input number (first argument) which should be >= 0
Parameters
Number - Input number
Returns
Number Result of a square root function
subtraction¶
Type
(-> Atom Atom %Undefined%)
Description
Function takes two non-deterministic inputs (first and second argument) and returns their subtraction. E.g. !(subtraction (superpose (a b b c)) (superpose (b c c d))) -> [a, b]
Parameters
Atom - Non-deterministic set of values
Atom - Another non-deterministic set of values
Returns
%Undefined% Subtraction of sets
subtraction-atom¶
Type
(-> Expression Expression Atom)
Description
Function takes two tuples and returns their subtraction. E.g. !(subtraction-atom (a b b c) (b c c d)) -> (a b)
Parameters
Expression - List of values
Expression - List of values
Returns
Atom Subtraction of sets
superpose¶
Type
(-> Expression %Undefined%)
Description
Turns a tuple (first argument) into a nondeterministic result
Parameters
Expression - Tuple to be converted
Returns
%Undefined% Argument converted to nondeterministic result
superpose-bind¶
Type
(-> Expression Atom)
Description
Complement to the collapse-bind. It takes result of collapse-bind (first argument) and returns only result atoms without bindings
Parameters
Expression - Expression in form (Atom Binding)
Returns
Atom Non-deterministic list of Atoms
switch¶
Type
(-> %Undefined% Expression %Undefined%)
Description
Subsequently tests multiple pattern-matching conditions (second argument) for the given value (first argument)
Parameters
%Undefined% - Atom to be matched with patterns
Expression - Tuple of pairs mapping condition patterns to results
Returns
%Undefined% Result which corresponds to the pattern which is matched with the passed atom first
switch-internal¶
Type
(-> Atom Expression Atom)
Description
This function is being called inside switch function to test one of the cases and it calls switch once again if current condition is not met
Parameters
Atom - Atom (it will be evaluated)
Expression - Deconsed tuple of pairs mapping condition patterns to results
Returns
Atom Result of evaluating of Atom bound to met condition
tan-math¶
Type
(-> Number Number)
Description
Returns result of the tangent function for an input value in radians (first argument)
Parameters
Number - Angle in radians
Returns
Number Result of the tangent function
trace!¶
Type
(-> %Undefined% Atom %Undefined%)
Description
Prints its first argument and returns second. Both arguments will be evaluated before processing
Parameters
%Undefined% - Atom to print
Atom - Atom to return
Returns
%Undefined% Evaluated second input
trunc-math¶
Type
(-> Number Number)
Description
Returns integer part of the input value (first argument)
Parameters
Number - Float value
Returns
Number Integer part of float
type-cast¶
Type
%Undefined%
Description
Casts atom passed as a first argument to the type passed as a second argument using space as a context
Parameters
%Undefined% - Atom to be casted
%Undefined% - Type to cast atom to
%Undefined% - Context atomspace
Returns
%Undefined% Atom if casting is successful, (Error ... BadType) otherwise
undefined-doc-function-type¶
Type
(-> Expression Type)
Description
Function used by get-doc-single-atom in case of absence of function's type notation
Parameters
Expression - List of parameters for the function we want to get documentation for
Returns
Type List of %Undefined% number of which depends on input list size. So for two parameters function will return (%Undefined% %Undefined% %Undefined%)
unify¶
Type
(-> Atom Atom Atom Atom %Undefined%)
Description
Matches two first arguments and returns third argument if they are matched and forth argument otherwise
Parameters
Atom - First atom to unify with
Atom - Second atom to unify with
Atom - Result if two atoms unified successfully
Atom - Result otherwise
Returns
%Undefined% Third argument when first two atoms are matched of forth one otherwise
union¶
Type
(-> Atom Atom %Undefined%)
Description
Function takes two non-deterministic inputs (first and second argument) and returns their union. E.g. (union (superpose (a b b c)) (superpose (b c c d))) -> [a, b, b, c, b, c, c, d]
Parameters
Atom - Non-deterministic set of values
Atom - Another non-deterministic set of values
Returns
%Undefined% Union of sets
union-atom¶
Type
(-> Expression Expression Atom)
Description
Function takes two tuples and returns their union. E.g. (union-atom (a b b c) (b c c d)) -> (a b b c b c c d)
Parameters
Expression - List of values
Expression - List of values
Returns
Atom Union of sets
unique¶
Type
(-> Atom %Undefined%)
Description
Function takes non-deterministic input (first argument) and returns only unique entities. E.g. (unique (superpose (a b c d d))) -> [a, b, c, d]
Parameters
Atom - Non-deterministic set of values
Returns
%Undefined% Unique values from input set
unique-atom¶
Type
(-> Expression Atom)
Description
Function takes tuple and returns only unique entities. E.g. (unique-atom (a b c d d)) -> (a b c d)
Parameters
Expression - List of values
Returns
Atom Unique values from input set
unquote¶
Type
(-> %Undefined% %Undefined%)
Description
Unquotes quoted atom, e.g. (unquote (quote $x)) returns $x
Parameters
%Undefined% - Quoted atom
Returns
%Undefined% Unquoted atom
xor¶
Type
(-> Bool Bool Bool)
Description
Logical exclusive or
Parameters
Bool - First argument
Bool - Second argument
Returns
Bool Returns True if one and only one of the inputs is True