, where
symbol was the symbol entered by the user, and number is a unique
number. This scheme was used
to such a generated symbol can not accientally be entered by a user.
Example:
In> LocalSymbols(a,b)a+b
Out> $a6+ $b6;
|
This is useful in cases where a guaranteed free variable is needed,
like in the macro-like functions (For, While, etc.).
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)
WithValue(variable,value,expression)
WithValue(variable,value,expression) : evaluate expression, with
variable set to value. variable and value can be lists of
variables and values.
SetHelpBrowser
Standard math library
Calling Sequence:
SetHelpBrowser(helpbrowser)
Parameters:
helpbrowser - string containing a html browser to use for help
Description:
This function sets the help browser you want to use to
browse the help online. It calls helpbrowser with the html
page as first argument. The default is lynx. If you want to
use a different browser by default it suffices to create a
file ~/.yacasrc. and add a line to set the browser in there.
Examples:
In> SetHelpBrowser("netscape")
Out> "netscape";
In> ??
|
See Also:
TraceStack
Internal function
Calling Sequence:
TraceStack(expression)
Parameters:
expression - an expression to evaluate
Description:
TraceStack shows the calling stack after an error occurred.
It shows the last few items on the stack, not to flood the screen.
These are usually the only items of interest on the stack.
This is probably by far the most useful debugging function in
Yacas. It shows the last few things it did just after an error
was generated somewhere.
For each stack frame, it shows if the function evaluated was a
built-in function or a user-defined function, and for the user-defined
function, the number of the rule it is trying whether it was evaluating
the pattern matcher of the rule, or the body code of the rule.
This functionality is not offered by default because it slows
down the evaluation code.
Examples:
Here is an example of a function calling itself recursively,
causing Yacas to flood its stack:
In> f(x):=f(Sin(x))
Out> True;
In> TraceStack(f(2))
Debug> 982 : f (Rule # 0 in body)
Debug> 983 : f (Rule # 0 in body)
Debug> 984 : f (Rule # 0 in body)
Debug> 985 : f (Rule # 0 in body)
Debug> 986 : f (Rule # 0 in body)
Debug> 987 : f (Rule # 0 in body)
Debug> 988 : f (Rule # 0 in body)
Debug> 989 : f (Rule # 0 in body)
Debug> 990 : f (Rule # 0 in body)
Debug> 991 : f (Rule # 0 in body)
Debug> 992 : f (Rule # 0 in body)
Debug> 993 : f (Rule # 0 in body)
Debug> 994 : f (Rule # 0 in body)
Debug> 995 : f (User function)
Debug> 996 : Sin (Rule # 0 in pattern)
Debug> 997 : IsList (Internal function)
Error on line 1 in file [CommandLine]
Max evaluation stack depth reached.
Please use MaxEvalDepth to increase the stack size as needed.
|
See Also:
TraceExp
,
TraceRule
,
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.
An example invocation of TraceRule is
In( 1 ) = TraceRule(x+y)2+3*5+4;
|
Which should then show something to the effect of
ENTER:2+3*5+4 ENTER:2+3*5 ARG:2 <- 2 ARG:3*5 <- 15 LEAVE:2+3*5 -> 17 ARG:2+3*5 <- 17 ARG:4 <- 4 LEAVE:2+3*5+4 -> 21 Out( 0 ) = 21;
|