Mercurial > octave
comparison scripts/general/structfun.m @ 30893:e1788b1a315f
maint: Use "fcn" as preferred abbreviation for "function" in m-files.
* accumarray.m, accumdim.m, quadl.m, quadv.m, randi.m, structfun.m,
__is_function__.m, uigetfile.m, uimenu.m, uiputfile.m, doc_cache_create.m,
colorspace_conversion_input_check.m, imageIO.m, argnames.m, vectorize.m,
vectorize.m, normest1.m, inputname.m, nthargout.m, display_info_file.m,
decic.m, ode15i.m, ode15s.m, ode23.m, ode23s.m, ode45.m, odeset.m,
check_default_input.m, integrate_adaptive.m, ode_event_handler.m,
runge_kutta_23.m, runge_kutta_23s.m, runge_kutta_45_dorpri.m,
runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m,
fminsearch.m, fminunc.m, fsolve.m, fzero.m, sqp.m, fplot.m, plotyy.m,
__bar__.m, __ezplot__.m, flat_entry.html, profexport.m, movfun.m, bicg.m,
bicgstab.m, cgs.m, eigs.m, gmres.m, pcg.m, __alltohandles__.m, __sprand__.m,
qmr.m, tfqmr.m, dump_demos.m:
Replace "func", "fun", "fn" in documentation and variable names with "fcn".
author | Rik <rik@octave.org> |
---|---|
date | Mon, 04 Apr 2022 18:14:56 -0700 |
parents | 5d3faba0342e |
children | 597f3ee61a48 |
comparison
equal
deleted
inserted
replaced
30892:1a3cc2811090 | 30893:e1788b1a315f |
---|---|
22 ## <https://www.gnu.org/licenses/>. | 22 ## <https://www.gnu.org/licenses/>. |
23 ## | 23 ## |
24 ######################################################################## | 24 ######################################################################## |
25 | 25 |
26 ## -*- texinfo -*- | 26 ## -*- texinfo -*- |
27 ## @deftypefn {} {@var{A} =} structfun (@var{func}, @var{S}) | 27 ## @deftypefn {} {@var{A} =} structfun (@var{fcn}, @var{S}) |
28 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "ErrorHandler", @var{errfunc}) | 28 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "ErrorHandler", @var{errfcn}) |
29 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "UniformOutput", @var{val}) | 29 ## @deftypefnx {} {@var{A} =} structfun (@dots{}, "UniformOutput", @var{val}) |
30 ## @deftypefnx {} {[@var{A}, @var{B}, @dots{}] =} structfun (@dots{}) | 30 ## @deftypefnx {} {[@var{A}, @var{B}, @dots{}] =} structfun (@dots{}) |
31 ## | 31 ## |
32 ## Evaluate the function named @var{name} on the fields of the structure | 32 ## Evaluate the function named @var{name} on the fields of the structure |
33 ## @var{S}. The fields of @var{S} are passed to the function @var{func} | 33 ## @var{S}. The fields of @var{S} are passed to the function @var{fcn} |
34 ## individually. | 34 ## individually. |
35 ## | 35 ## |
36 ## @code{structfun} accepts an arbitrary function @var{func} in the form of an | 36 ## @code{structfun} accepts an arbitrary function @var{fcn} in the form of an |
37 ## inline function, function handle, or the name of a function (in a character | 37 ## inline function, function handle, or the name of a function (in a character |
38 ## string). In the case of a character string argument, the function must | 38 ## string). In the case of a character string argument, the function must |
39 ## accept a single argument named @var{x}, and it must return a string value. | 39 ## accept a single argument named @var{x}, and it must return a string value. |
40 ## If the function returns more than one argument, they are returned as | 40 ## If the function returns more than one argument, they are returned as |
41 ## separate output variables. | 41 ## separate output variables. |
55 ## name1 = Smith | 55 ## name1 = Smith |
56 ## name2 = Jones | 56 ## name2 = Jones |
57 ## @end group | 57 ## @end group |
58 ## @end example | 58 ## @end example |
59 ## | 59 ## |
60 ## Given the parameter @qcode{"ErrorHandler"}, @var{errfunc} defines a function | 60 ## Given the parameter @qcode{"ErrorHandler"}, @var{errfcn} defines a function |
61 ## to call in case @var{func} generates an error. The form of the function is | 61 ## to call in case @var{fcn} generates an error. The form of the function is |
62 ## | 62 ## |
63 ## @example | 63 ## @example |
64 ## function [@dots{}] = errfunc (@var{se}, @dots{}) | 64 ## function [@dots{}] = errfcn (@var{se}, @dots{}) |
65 ## @end example | 65 ## @end example |
66 ## | 66 ## |
67 ## @noindent | 67 ## @noindent |
68 ## where there is an additional input argument to @var{errfunc} relative to | 68 ## where there is an additional input argument to @var{errfcn} relative to |
69 ## @var{func}, given by @nospell{@var{se}}. This is a structure with the | 69 ## @var{fcn}, given by @nospell{@var{se}}. This is a structure with the |
70 ## elements @qcode{"identifier"}, @qcode{"message"} and @qcode{"index"}, | 70 ## elements @qcode{"identifier"}, @qcode{"message"} and @qcode{"index"}, |
71 ## giving respectively the error identifier, the error message, and the index | 71 ## giving respectively the error identifier, the error message, and the index |
72 ## into the input arguments of the element that caused the error. For an | 72 ## into the input arguments of the element that caused the error. For an |
73 ## example on how to use an error handler, @pxref{XREFcellfun,,@code{cellfun}}. | 73 ## example on how to use an error handler, @pxref{XREFcellfun,,@code{cellfun}}. |
74 ## | 74 ## |
75 ## @seealso{cellfun, arrayfun, spfun} | 75 ## @seealso{cellfun, arrayfun, spfun} |
76 ## @end deftypefn | 76 ## @end deftypefn |
77 | 77 |
78 function varargout = structfun (func, S, varargin) | 78 function varargout = structfun (fcn, S, varargin) |
79 | 79 |
80 if (nargin < 2) | 80 if (nargin < 2) |
81 print_usage (); | 81 print_usage (); |
82 endif | 82 endif |
83 | 83 |
103 if (nargs > 0) | 103 if (nargs > 0) |
104 error ("structfun: invalid options"); | 104 error ("structfun: invalid options"); |
105 endif | 105 endif |
106 | 106 |
107 varargout = cell (max ([nargout, 1]), 1); | 107 varargout = cell (max ([nargout, 1]), 1); |
108 [varargout{:}] = cellfun (func, struct2cell (S), varargin{:}); | 108 [varargout{:}] = cellfun (fcn, struct2cell (S), varargin{:}); |
109 | 109 |
110 if (! uniform_output) | 110 if (! uniform_output) |
111 varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, ... | 111 varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, ... |
112 uo_str, false); | 112 uo_str, false); |
113 endif | 113 endif |