Mercurial > hg > octave-terminal
changeset 9784:f786dca09f79
implement nfields
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sun, 08 Nov 2009 21:25:46 +0100 |
parents | 119d97db51f0 |
children | ccad98db781b |
files | src/ov-struct.cc |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -922,6 +922,26 @@ return retval; } +DEFUN (nfields, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} nfields (@var{s})\n\ +Return the number of fields of the structure @var{s}.\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin == 1 && args(0).is_map ()) + { + retval = static_cast<double> (args(0).nfields ()); + } + else + print_usage (); + + return retval; +} + // Check that the dimensions of the input arguments are correct. static bool