aboutsummaryrefslogtreecommitdiff
path: root/matlab/types.m
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-02-08 13:18:08 -0600
committerJoel Martin <github@martintribe.org>2015-02-08 23:51:22 -0600
commit6d12affa8bc91a6662e8d4bdcc66a6963b77e947 (patch)
tree644d5a482081600faafc09e679fb1006796de659 /matlab/types.m
parentd6624158bdf41e047ad8d0a9942238dc80649901 (diff)
downloadmal-6d12affa8bc91a6662e8d4bdcc66a6963b77e947.tar.gz
mal-6d12affa8bc91a6662e8d4bdcc66a6963b77e947.zip
matlab: all step4 except optional.
Diffstat (limited to 'matlab/types.m')
-rw-r--r--matlab/types.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/matlab/types.m b/matlab/types.m
index cb3bf8f..7263fb2 100644
--- a/matlab/types.m
+++ b/matlab/types.m
@@ -2,5 +2,31 @@ classdef types
properties (Constant = true)
nil = types.Nil();
end
+
+ methods(Static)
+ function ret = equal(a,b)
+ ret = false;
+ ota = class(a); otb = class(b);
+ if ~(strcmp(ota,otb) || (iscell(a) && iscell(b)))
+ return;
+ end
+ switch (ota)
+ case 'cell'
+ if ~(length(a) == length(b))
+ return
+ end
+ for i=1:length(a)
+ if ~(types.equal(a{i}, b{i}))
+ return
+ end
+ end
+ ret = true;
+ case 'char'
+ ret = strcmp(a,b);
+ otherwise
+ ret = a == b;
+ end
+ end
+ end
end