tree2code
generates the text definition of a Scilab function from its internal code
Syntax
txt = tree2code(tree, prettyprint)
Arguments
- tree
a macro internal tree (coming from
macr2tree).- prettyprint
an optional boolean value:
%T : The generated code is indented and beautified. The indentation length is the Scinotes one. It can be tuned through Scinotes preferences. %F : The generated code is not beautified (default) - txt
column of texts: Scilab instructions defining the function
Description
Given a loaded Scilab function "tree" (returned by macr2tree),
tree2code allows to re-generate the code defining the function.
Examples
tree = macr2tree(log2); // note that the input is log2 (the function handle), not "log2" txt = tree2code(tree, %T); printf("%s\n", txt);
--> printf("%s\n",c)
function [f,e] = log2(x)
// x may be positive, negative, or complex
[lhs,rhs] = argn(0)
if rhs<>1 then
msg = gettext("%s: Wrong number of input argument(s): %d expected.\n")
error(msprintf(msg, "log2", 1))
end;
if argn(1)==1 then
f = log(x)/log(2)
else
[f,e] = frexp(x)
end
endfunction
See also
| Report an issue | ||
| << overloading | Advanced functions | varargin >> |