~ubuntu-branches/ubuntu/wily/octave-miscellaneous/wily

« back to all changes in this revision

Viewing changes to inst/apply.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere, Sébastien Villemot
  • Date: 2012-10-17 13:40:55 UTC
  • mfrom: (1.2.1) (12 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20121017134055-vatltexghy77fnv7
Tags: 1.2.0-1
[ Rafael Laboissiere ]
* Imported Upstream version 1.2.0
* Bump Standards-Version to 3.9.4 (no changes needed)
* Refresh for new upstream release
* Use Sébastien Villemot's @debian.org email address
* Remove obsolete DM-Upload-Allowed flag
* Add patch autoload-yes.patch
* Add copyright info for file lauchli.m (included in a Debian patch)
* Add patch partcnt-test-succeeds.patch
* Build-depends on octave-pkg-dev >= 1.0.3

[ Sébastien Villemot ]
* debian/control: fix versioned dependency on debhelper
* Add lintian override for false positive on hardening (fortify)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
## Copyright (C) 2007, Muthiah Annamalai
2
 
##
3
 
## Apply function like in LISP. Pass a (row only)cell-array of arguments,
4
 
## supplied on invoking the function.
5
 
##
6
 
## This program is free software; you can redistribute it and/or modify
7
 
## it under the terms of the GNU General Public License as published by
8
 
## the Free Software Foundation; either version 2 of the License, or
9
 
## (at your option) any later version.
10
 
##
11
 
## This program is distributed in the hope that it will be useful,
12
 
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
## GNU General Public License for more details. 
15
 
##
16
 
## You should have received a copy of the GNU General Public License
17
 
## along with this program; if not, see <http://www.gnu.org/licenses/>.
18
 
##
 
1
## Copyright (C) 2007, Muthiah Annamalai <muthiah.annamalai@uta.edu>
 
2
##
 
3
## This program is free software; you can redistribute it and/or modify it under
 
4
## the terms of the GNU General Public License as published by the Free Software
 
5
## Foundation; either version 3 of the License, or (at your option) any later
 
6
## version.
 
7
##
 
8
## This program is distributed in the hope that it will be useful, but WITHOUT
 
9
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
10
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 
11
## details.
 
12
##
 
13
## You should have received a copy of the GNU General Public License along with
 
14
## this program; if not, see <http://www.gnu.org/licenses/>.
19
15
 
20
16
## -*- texinfo -*-
21
17
## @deftypefn {Loadable Function} {@var{return_value} =} apply (@var{@@function_handle},@var{cell_array_of_args})
26
22
## @var{function_handle}(arg1, arg2, ... ,argn), where the arguments are 
27
23
## extracted from each elements of the 1-row cell array @var{cell_array_of_args}. 
28
24
##
 
25
## @emph{warning}: @code{apply} has been deprecated in favor of @code{arrayfun}
 
26
## and @code{cellfun} for arrays and cells respectively. This function will be
 
27
## removed from future versions of the 'miscellaneous' package".
 
28
##
29
29
## Apply also works on array of function handles if
30
30
## @var{function_handle} is passed as a cell array of a handles; in this
31
31
## case apply, evaluates each function (using the handle) with the same
55
55
 
56
56
function rval=apply(fun_handle,cell_array)
57
57
 
 
58
  persistent warned = false;
 
59
  if (! warned)
 
60
    warned = true;
 
61
    warning ("Octave:deprecated-function",
 
62
             "apply has been deprecated, and will be removed in the future. Use `arrayfun' or `cellfun' instead.");
 
63
  endif
 
64
 
58
65
  if (nargin == 0)
59
66
    print_usage();
60
67
    error("apply(): needs at least 1 argument, see usage");
61
68
  elseif( nargin < 2)
62
69
    if iscell(fun_handle)
63
70
      for idx=1:length(fun_handle)
64
 
        rval(idx)=feval(@feval,fun_handle{idx});
 
71
        rval(idx)=feval(@feval,fun_handle{idx});
65
72
      end
66
73
    else
67
74
      rval=feval(@feval,fun_handle);