Mercurial > hg > octave-lyh
diff scripts/general/structfun.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | fd0a3ac60b0e |
children | cefd568ea073 |
line wrap: on
line diff
--- a/scripts/general/structfun.m +++ b/scripts/general/structfun.m @@ -22,15 +22,15 @@ ## @deftypefnx {Function File} {[@var{A}, @dots{}] =} structfun (@dots{}) ## @deftypefnx {Function File} {} structfun (@dots{}, "ErrorHandler", @var{errfunc}) ## @deftypefnx {Function File} {} structfun (@dots{}, "UniformOutput", @var{val}) -## +## ## Evaluate the function named @var{name} on the fields of the structure ## @var{S}. The fields of @var{S} are passed to the function @var{func} ## individually. ## -## @code{structfun} accepts an arbitrary function @var{func} in the form of -## an inline function, function handle, or the name of a function (in a -## character string). In the case of a character string argument, the -## function must accept a single argument named @var{x}, and it must return +## @code{structfun} accepts an arbitrary function @var{func} in the form of +## an inline function, function handle, or the name of a function (in a +## character string). In the case of a character string argument, the +## function must accept a single argument named @var{x}, and it must return ## a string value. If the function returns more than one argument, they are ## returned as separate output variables. ## @@ -40,35 +40,35 @@ ## return value. If "UniformOutput" is false, the outputs are placed into a ## structure ## with the same fieldnames as the input structure. -## +## ## @example ## @group -## s.name1 = "John Smith"; -## s.name2 = "Jill Jones"; -## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s, +## s.name1 = "John Smith"; +## s.name2 = "Jill Jones"; +## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s, ## "UniformOutput", false) ## @result{} ## @{ ## name1 = Smith ## name2 = Jones -## @} +## @} ## @end group ## @end example -## +## ## Given the parameter "ErrorHandler", @var{errfunc} defines a function to ## call in case @var{func} generates an error. The form of the function is -## +## ## @example ## function [@dots{}] = errfunc (@var{se}, @dots{}) ## @end example -## +## ## @noindent ## where there is an additional input argument to @var{errfunc} relative to ## @var{func}, given by @var{se}. This is a structure with the elements ## "identifier", "message" and "index", giving respectively the error ## identifier, the error message, and the index into the input arguments ## of the element that caused the error. For an example on how to use -## an error handler, @pxref{doc-cellfun, @code{cellfun}}. +## an error handler, @pxref{doc-cellfun, @code{cellfun}}. ## ## @seealso{cellfun, arrayfun, spfun} ## @end deftypefn @@ -112,11 +112,11 @@ %!test -%! s.name1 = "John Smith"; -%! s.name2 = "Jill Jones"; +%! s.name1 = "John Smith"; +%! s.name2 = "Jill Jones"; %! l.name1 = "Smith"; %! l.name2 = "Jones"; -%! o = structfun (@(x) regexp (x, '(\w+)$', "matches"){1}, s, +%! o = structfun (@(x) regexp (x, '(\w+)$', "matches"){1}, s, %! "UniformOutput", false); %! assert (o, l);