diff src/mappers.cc @ 8387:1567db1e166c

make upper and lower aliases of toupper and tolower respectively
author Thorsten Meyer <thorsten.meyier@gmx.de>
date Tue, 09 Dec 2008 12:04:11 +0100
parents 8b1a2555c4e2
children 502e58a0d44f
line wrap: on
line diff
--- a/src/mappers.cc
+++ b/src/mappers.cc
@@ -1569,9 +1569,10 @@
 DEFUNX ("tolower", Ftolower, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Mapping Function} {} tolower (@var{s})\n\
-Return a copy of the string @var{s}, with each upper-case character\n\
-replaced by the corresponding lower-case one; nonalphabetic characters\n\
-are left unchanged.  For example,\n\
+@deftypefnx {Mapping Function} {} lower (@var{s})\n\
+Return a copy of the string or cell string @var{s}, with each upper-case\n\
+character replaced by the corresponding lower-case one; nonalphabetic\n\
+characters are left unchanged.  For example,\n\
 \n\
 @example\n\
 tolower (\"MiXeD cAsE 123\")\n\
@@ -1588,12 +1589,33 @@
   return retval;
 }
 
+DEFALIAS (lower, tolower);
+
+/*
+ 
+%!error <Invalid call to tolower.*> tolower();
+%!error <Invalid call to tolower.*> lower();
+%!assert(tolower("OCTAVE"), "octave");
+%!assert(tolower("123OCTave!_&"), "123octave!_&");
+%!assert(tolower({"ABC", "DEF", {"GHI", {"JKL"}}}), {"abc", "def", {"ghi", {"jkl"}}});
+%!assert(tolower(["ABC"; "DEF"]), ["abc"; "def"]);
+%!assert(tolower({["ABC"; "DEF"]}), {["abc";"def"]});
+%!assert(tolower(68), "d");
+%!assert(tolower({[68, 68; 68, 68]}), {["dd";"dd"]});
+%!test
+%!  a(3,3,3,3) = "D";
+%!  assert(tolower(a)(3,3,3,3), "d");
+
+*/
+
+
 DEFUNX ("toupper", Ftoupper, args, ,
     "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} toupper (@var{s})\n\
-Return a copy of the string @var{s}, with each  lower-case character\n\
-replaced by the corresponding upper-case one; nonalphabetic characters\n\
-are left unchanged.  For example,\n\
+@deftypefnx {Built-in Function} {} upper (@var{s})\n\
+Return a copy of the string or cell string @var{s}, with each  lower-case\n\
+character replaced by the corresponding upper-case one; nonalphabetic\n\
+characters are left unchanged.  For example,\n\
 \n\
 @example\n\
 @group\n\
@@ -1612,6 +1634,25 @@
   return retval;
 }
 
+DEFALIAS (upper, toupper);
+
+/*
+ 
+%!error <Invalid call to toupper.*> toupper();
+%!error <Invalid call to toupper.*> upper();
+%!assert(toupper("octave"), "OCTAVE");
+%!assert(toupper("123OCTave!_&"), "123OCTAVE!_&");
+%!assert(toupper({"abc", "def", {"ghi", {"jkl"}}}), {"ABC", "DEF", {"GHI", {"JKL"}}});
+%!assert(toupper(["abc"; "def"]), ["ABC"; "DEF"]);
+%!assert(toupper({["abc"; "def"]}), {["ABC";"DEF"]});
+%!assert(toupper(100), "D");
+%!assert(toupper({[100, 100; 100, 100]}), {["DD";"DD"]});
+%!test
+%!  a(3,3,3,3) = "d";
+%!  assert(toupper(a)(3,3,3,3), "D");
+
+*/
+
 DEFALIAS (gammaln, lgamma);
 
 DEFALIAS (isfinite, finite);