11.10.2 Подфункции
Файл функции может содержать вторичные функции, называемые подфункциями. Эти вторичные функции видны только другим функциям в том же файле функции. Например, файл f.m содержащий
function f ()
printf ("in f, calling g\n");
g ()
endfunction
function g ()
printf ("in g, calling h\n");
h ()
endfunction
function h ()
printf ("in h\n")
endfunction определяет главную функцию f и две подфункции. Подфункции g и h могут вызываться только из главной функции f или из других подфункций, но не извне файла f.m.
- : subfcn_list = localfunctions () ¶
-
Возвращает список всех локальных функций, то есть подфункций, внутри текущего файла.
Возвращаемое значение — это столбцовая ячейка массивов дескрипторов функций всех локальных функций, доступных из функции, из которой
localfunctionsвызывается. Вложенные функции не включаются в список.Если вызов происходит из командной строки, анонимной функции или скрипта, возвращаемое значение — пустой ячейковый массив.
См. также: функции.
© 1996–2023 The Octave Project Developers
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://docs.octave.org/v8.1.0/Subfunctions.html