view examples/celldemo.cc @ 14136:20cb178716ee

Make nargin and nargout behave more like Matlab's (Bug #32700) * ov-usr-fcn.cc: Include "ov-fcn-handle.h". (Fnargout, Fnargin) nargout can be given a function handle as well as a string. Allow nargout(fcn) works in the top level. Make inline functions always return 1. Make anonymous functions always return -1. Make functions with varargout optionally preceded by named outputs return -(length_output_list_including_the_varargout).
author Iain Murray <iain@iainmurray.net>
date Mon, 02 Jan 2012 12:49:52 -0500
parents db1f49eaba6b
children be41c30bcb44
line wrap: on
line source

#include <octave/oct.h>
#include <octave/Cell.h>

DEFUN_DLD (celldemo, args, , "Cell Demo")
{
  octave_value_list retval;
  int nargin = args.length ();

  if (nargin != 1)
    print_usage ();
  else
    {
      Cell c = args (0).cell_value ();
      if (! error_state)
        for (octave_idx_type i = 0; i < c.nelem (); i++)
          retval(i) = c.elem (i);
    }

  return retval;
}