# HG changeset patch # User Juan Pablo Carbajal # Date 1326083195 28800 # Node ID 3972c4caa60ac7b6f36841da919454757e0004c6 # Parent 447b57ebc27b6b6be2bcaf1f17871a13f438d1e2 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 (). diff -r 447b57ebc27b -r 3972c4caa60a doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Sun Jan 08 19:23:55 2012 -0500 +++ b/doc/interpreter/contributors.in Sun Jan 08 20:26:35 2012 -0800 @@ -25,6 +25,7 @@ Marco Caliari Daniel Calvelo John C. Campbell +Juan Pablo Carbajal Jean-Francois Cardoso Joao Cardoso Larrie Carr diff -r 447b57ebc27b -r 3972c4caa60a doc/interpreter/func.txi --- a/doc/interpreter/func.txi Sun Jan 08 19:23:55 2012 -0500 +++ b/doc/interpreter/func.txi Sun Jan 08 20:26:35 2012 -0800 @@ -1145,6 +1145,8 @@ @end group @end example +@DOCSTRING(is_function_handle) + @DOCSTRING(functions) @DOCSTRING(func2str) diff -r 447b57ebc27b -r 3972c4caa60a src/ov-fcn-handle.cc --- a/src/ov-fcn-handle.cc Sun Jan 08 19:23:55 2012 -0500 +++ b/src/ov-fcn-handle.cc Sun Jan 08 20:26:35 2012 -0800 @@ -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,