Mercurial > hg > octave-lojdl
changeset 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 | 447b57ebc27b |
children | fbfaafe0471b |
files | doc/interpreter/contributors.in doc/interpreter/func.txi src/ov-fcn-handle.cc |
diffstat | 3 files changed, 35 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -25,6 +25,7 @@ Marco Caliari Daniel Calvelo John C. Campbell +Juan Pablo Carbajal Jean-Francois Cardoso Joao Cardoso Larrie Carr
--- a/doc/interpreter/func.txi +++ b/doc/interpreter/func.txi @@ -1145,6 +1145,8 @@ @end group @end example +@DOCSTRING(is_function_handle) + @DOCSTRING(functions) @DOCSTRING(func2str)
--- 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,