Atom("atom") :
Returns an atom with the string representation given
as the evaluated argument. Example: "Atom("foo");" returns
"foo".
String(atom)
String(atom) : Inverse of Atom: turns atom into "atom".
ConcatStrings(strings)
ConcatStrings(strings) :
Concatenate strings. Example:
"ConcatStrings("a","b","c");" will return "abc".
/* comment */
A comment block in a source file.
Prog(...)
Prog(...) : Evaluate the arguments in order, and return the result of the
last evaluated expression.
This is the same as the "[ ... ]" constuct, that
is, "Prog(a,b);" is the same as typing "[a;b;];" and is
very useful for writing out function bodies (the "[...]" construct
is converted into "Prog(...)" during the parsing stage)
While(predicate) body
While(predicate) body :
Keep on evaluating "body" while "predicate"
evaluates to "True". "predicate" is tested
before evaluating the body. While returns "True".
If(predicate,then,else)
If(predicate,then,else) :
If statement. If "predicate" evaluates to
"True", return result of evaluating the
"then" body, else if there is a "else" body,
return that result, otherwise return "False".
Check(predicate,"error")
Check(predicate,"error") :
If "predicate" doesn't evaluate to "True",
then current operation will be stopped, and execution
will jump right back to the command line, showing
"error". Use this to assure that some condition
is met during evaluation of expressions (guarding
against internal errors).
SystemCall(string)
SystemCall(string) :
This will call a command in the surrounding shell Yacas was invoked
from. SystemCall can be used to pass commands to other programs
or the operating system.
PreFix("operator")
PreFix("operator") : Defines a new operator for the prefix parser to understand.
PostFix("oper")
PostFix("oper") : Defines a new operator for the postfix parser to understand.
Bodied("oper")
Bodied("oper") : Defines a new operator for the bodied parser to understand.
InFix("operator",precedence)
InFix("operator",precedence) : Defines a new operator for the infix parser to understand.
"precedence" is evaluated.
IsInFix("str"), IsPreFix("str"), IsPostFix("str")
Returns wether str is an infix, prefix, or postfix operator.
IsInFix("+") should return True. IsInFix("a") should return False.
OpPrecedence("str")
Returns the precedence of the infix operator str. OpPrecedence("+")
should return 6.
RightAssociative("operator")
makes the operator right-associative. Example: RightAssociative("*")
would make multiplication right-associative. Take care not to abuse
this function, because the reverse, making an infix operator
left-associative, is not implemented.
oper should be an infix operator. This function call tells the
infix expression printer to bracket the left or right hand side of
the expression if its precedence is larger than precedence.
This functionality was required in order to display a-(b-c)
correctly. a+b+c is the same as a+(b+c), but a-(b-c) is not
the same as a-b-c.
RuleBase("operator",{params})
RuleBase("operator",{params}) : Define a new rules table entry for a
function "operator", with {params} as the parameter list.
Rule("operator",arity,precedence,predicate) body
Rule("operator",arity,precedence,predicate) body :
Define a rule for the function "operator" with
"arity", "precedence", "predicate" and
"body". "precedence" is checked from low to high.
The arity for a rules database equals the number of arguments. Different
rules data bases can be built for functions with the same name but with
a different number of arguments.
Rules with a low value will be tried before rules with a high value, so
a rule with precedence 0 will be tried before a rule with precedence 1.
HoldArg("operator",parameter)
HoldArg("operator",parameter) :
Specify that parameter (which should be part of
a parameter list for a function "operator") should
not be evaluated before used. This will be
declared for all arities of "operator", at the moment
this function is called, so it is best called
after all RuleBase calls for this operator.
TryRetract("operator",arity)
TryRetract("operator",arity) : Remove a rulebase with some specific arity,
if it exists at all.
UnFence("operator",arity)
UnFence("operator",arity) : When applied to a user function, the bodies
defined for the rules for "operator" with given
arity can see the local variables from the calling
function. This is useful for defining macro-like
procedures (looping and the such). The For and ForEach functions
defined in the standard packages use this, for instance.
Same as their non-macro counterparts, except
that their arguments are evaluated before
the required action is performed. This is
useful in macro-like procedures.
Function("operator",{arguments} ) body
Function("operator",{arguments} ) body :
Use this to declare a simple function, one that doesn't need an entire
rules data base.
Uses("file")
Uses("file") :
This function loads a file if it was not already loaded with Uses.
Type(expression)
Type(expression) :
Returns a string representation of the type of "expression".
"Type(Cos(x));" would evaluate to "Cos", for instance.
NrArgs(expression)
NrArgs(expression) :
Returns number of arguments in top-level function of "expression".
"NrArgs(Cos(x));" would evaluate to "1".
For(start,predicate,increment) body
For(start,predicate,increment) body :
Looping in a C style. "start" gets called, and then "body" as
long as "predicate" evaluates to True", evaluating
"increment" each time after body was evaluated. Returns "True".
ForEach(item,{list}) body
ForEach(item,{list}) body :
This function loops over each element in {list}, assigning it to
the variable "item", and calling "body". Returns "True".
Apply("oper",{list})
Apply("oper",{list}) :
This function applies a operator to the arguments mentioned in the list.
Eg. "Apply("+",{2,3});" would evaluate to "5".
You can also apply pure functions, declared using the form {varlist,body}.
Example: "Apply( {{x,y},x+y} , {2,3} );" would also evaluate to 5.
BubbleSort({list},"compare")
BubbleSort({list},"compare") :
Sort the list {list}, using "compare" as the operator to compare
elements. "compare" gives the relation that should be true for
neighbouring elements in the list after sorting.
Table(body,var,from,to,step)
Table(body,var,from,to,step) :
Generate a list of values from "body", by assigning variable "var"
values from "from" upto "to", incrementing "step" each time.
TableForm({list})
Tableform({list}) :
TableForm writes out a list in a nicer readable form, eg. one line for
each element in the list.
MapSingle("operator",{list})
MapSingle("operator",{list}) :
MapSingle performs Apply on every item in {list}, returning a
list of the results.
Map("operator",{lists})
Map("operator",{lists}) :
{lists} should be a list of lists each the same size.
Map performs Apply on every set of items in {lists}, returning a
list of the results. Eg. Map("+",{{1,2},{2,3}}) would return {3,5}.
Secure(body)
Secure evaluates body in a safe environment, where file opening
and system calls are not allowed. This can protect the system
when an unsafe evaluation is done (Like a script sent over the
internet to be evaluated on a computer).
Subst(from,to)body
Subst replaces any occurrence of from in body with to.
Example:
Subst(x,Sin(y)) x+x -> Sin(y)+Sin(y)
TraceExp(expression)
TraceExp(expression) : turn on tracing facility, and evaluate
expression. This is useful for tracing the evaluation of small
routines interactively from the command line.
Tracerule(template)expression
Tracerule(template)expression : turn on tracing facility given
the template, and evaluate expression. the template is an example
of the function to trace on. template=x+y would trace all additions,
showing the arguments passed in, and the result of the addition.
Only user-defined functions can be traced.
This is useful for tracing a function that is called from within
another function. This way you can see how your function behaves
in the environment it is used in.