« Return to Thread: [Changeset] isa function with float and numeric arguments

[Changeset] isa function with float and numeric arguments

by David Bateman-3 :: Rate this Message:

Reply to Author | View in Thread

The isa function should allow the "float" and "numeric" arguments. The
attached patch adds this.

D.

# HG changeset patch
# User David Bateman <dbateman@...>
# Date 1210622234 -7200
# Node ID 66f4246ff15c7258328c916663857d0fbbdd5e96
# Parent  b3ba72dfbb1bcce79fe839d70cb0c73e97c57fda
Treat numeric and float argument in the isa function.

diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@ 2008-05-09  David Bateman  <dbateman@fre
+2008-05-12  David Bateman  <dbateman@...>
+
+ * general/isa.m: Also treat "float: and "numeric" as the class
+ argument.
+
 2008-05-09  David Bateman  <dbateman@...>
 
  * testfun/assert.m: Allow assert(cond, errmsg, ...) and
diff --git a/scripts/general/isa.m b/scripts/general/isa.m
--- a/scripts/general/isa.m
+++ b/scripts/general/isa.m
@@ -30,6 +30,15 @@ function retval = isa (x, cname)
     print_usage ();
   endif
 
-  retval = strcmp (class (x), cname);
-
+  if (strcmp (cname, "float"))
+    retval = strcmp (class (x), "double") || strcmp (class (x), "single");
+  elseif (strcmp (cname, "fnumeric"))
+    retval = strcmp (class (x), "double") || strcmp (class (x), "single") ||
+    strcmp (class (x), "uint8") || strcmp (class (x), "uint16") ||
+    strcmp (class (x), "uint32") || strcmp (class (x), "uint64") ||
+    strcmp (class (x), "int8") || strcmp (class (x), "int16") ||
+    strcmp (class (x), "int32") || strcmp (class (x), "int64");
+  else
+    retval = strcmp (class (x), cname);
+  endif
 endfunction

 « Return to Thread: [Changeset] isa function with float and numeric arguments

LightInTheBox - Buy quality products at wholesale price