Mercurial > hg > octave-nkf
diff src/ov-fcn-handle.cc @ 14175:3972c4caa60a stable
Add new function is_function_handle (patch #7695)
* contributors.in: Add Juan Pablo Carbajal to list of contributors.
* func.txi: Add docstring to function handle chapter.
* ov-fcn-handle.cc: Add new function is_function_handle ().
author | Juan Pablo Carbajal <carbajal@ifi.uzh.ch> |
---|---|
date | Sun, 08 Jan 2012 20:26:35 -0800 |
parents | 72c96de7a403 |
children | eff4a5933e28 |
line wrap: on
line diff
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -1776,6 +1776,38 @@ */ +DEFUN (is_function_handle, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} is_function_handle (@var{x})\n\ +Return true if @var{x} is a function handle.\n\ +@seealso{isa, typeinfo, class}\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin == 1) + retval = args(0).is_function_handle (); + else + print_usage (); + + return retval; +} + +/* +%!shared fh +%! fh = @(x) x; + +%!assert (is_function_handle (fh)) +%!assert (! is_function_handle ({fh})) +%!assert (! is_function_handle (1)) +%!error is_function_handle (); +%!error is_function_handle (1, 2); + +*/ + + octave_fcn_binder::octave_fcn_binder (const octave_value& f, const octave_value& root, const octave_value_list& templ,