changeset 9635:76a4607ba4aa octave-forge

map: deprecating function in favour of cellfun or arrayfun
author carandraug
date Mon, 12 Mar 2012 15:06:46 +0000
parents 210968b14f63
children b688d8814e55
files main/miscellaneous/NEWS main/miscellaneous/inst/apply.m main/miscellaneous/inst/map.m
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/main/miscellaneous/NEWS	Mon Mar 12 14:39:15 2012 +0000
+++ b/main/miscellaneous/NEWS	Mon Mar 12 15:06:46 2012 +0000
@@ -19,8 +19,8 @@
 
  ** The function clip was imported from the audio package.
 
- ** The function `apply' has been deprecated. `cellfun' and `arrayfun' from
-    octave core should be used instead.
+ ** The functions `apply' and `map' have been deprecated. `cellfun' and
+    `arrayfun' from octave core should be used instead.
 
  ** The function `partarray' has been removed. `mat2cell' from octave core
     should be used instead.
--- a/main/miscellaneous/inst/apply.m	Mon Mar 12 14:39:15 2012 +0000
+++ b/main/miscellaneous/inst/apply.m	Mon Mar 12 15:06:46 2012 +0000
@@ -59,9 +59,7 @@
   if (! warned)
     warned = true;
     warning ("Octave:deprecated-function",
-             "apply.m has been deprecated, and will be removed in the future.")
-    warning ("Octave:deprecated-function",
-             "Use `arrayfun' or `cellfun' instead.");
+             "apply has been deprecated, and will be removed in the future. Use `arrayfun' or `cellfun' instead.");
   endif
 
   if (nargin == 0)
@@ -70,7 +68,7 @@
   elseif( nargin < 2)
     if iscell(fun_handle)
       for idx=1:length(fun_handle)
-	rval(idx)=feval(@feval,fun_handle{idx});
+        rval(idx)=feval(@feval,fun_handle{idx});
       end
     else
       rval=feval(@feval,fun_handle);
--- a/main/miscellaneous/inst/map.m	Mon Mar 12 14:39:15 2012 +0000
+++ b/main/miscellaneous/inst/map.m	Mon Mar 12 15:06:46 2012 +0000
@@ -62,6 +62,13 @@
 
 function return_type = map (fun_handle, data_struct, varargin)
 
+  persistent warned = false;
+  if (! warned)
+    warned = true;
+    warning ("Octave:deprecated-function",
+             "map has been deprecated, and will be removed in the future. Use `arrayfun' or `cellfun' instead.");
+  endif
+
   if (nargin < 2)
     print_usage;
   elseif (!(isnumeric (data_struct) || iscell (data_struct)))