Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - Русский


tree2code

формирует ASCII-определение Scilab-функции

Синтаксис

txt = tree2code(tree, prettyprint)

Аргументы

tree

дерево функции (полученное с помощью macr2tree).

prettyprint

необязательное логическое значение:

%T : генерирует код, который имеет отступы и красивый вид. The indentation length is the Scinotes one. It can be tuned through Scinotes preferences.
%F : генерируемый код не приукрашен (по умолчанию)
txt

вектор-столбец строк, текст, предоставляющий Scilab-инструкции.

Описание

Задавая "дерево" загруженной в Scilab функции (полученное с помощью функции macr2tree), tree2code позволяет восстановить код.

Примеры

tree = macr2tree(log2);   // заметьте, что на входе указано log2 (дескриптор функции), а не "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

Смотрите также

  • macr2tree — Обеспечивает внутренний код скомпилированного функции Scilab
  • macrovar — переменные в функции
  • string — преобразование в строку
Report an issue
<< перегрузка Функции varargin >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:41:19 CEST 2023