diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-02-18 02:38:28 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-02-18 02:38:28 +0000 |
commit | b2f8fe721181e43ee4a1f0d1171b0c069f20e845 (patch) | |
tree | 3ef8bccf2722bf6f21ecce686db23cd6905b426c /src | |
parent | b8e333fb3437dca760f16136ed074a4dd463fe35 (diff) |
fixed LazySeq and EmptyList equals/equiv
Diffstat (limited to 'src')
-rw-r--r-- | src/jvm/clojure/lang/LazySeq.java | 10 | ||||
-rw-r--r-- | src/jvm/clojure/lang/PersistentList.java | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/jvm/clojure/lang/LazySeq.java b/src/jvm/clojure/lang/LazySeq.java index 1769d43f..824af56d 100644 --- a/src/jvm/clojure/lang/LazySeq.java +++ b/src/jvm/clojure/lang/LazySeq.java @@ -71,8 +71,7 @@ public class LazySeq extends AFn implements ISeq, List { } public boolean equiv(Object o) { - ISeq s = seq(); - return s == o || (s != null && s.equiv(o)); + return equals(o); } public int hashCode() { @@ -81,7 +80,12 @@ public class LazySeq extends AFn implements ISeq, List { public boolean equals(Object o) { ISeq s = seq(); - return s == o || (s != null && s.equals(o)); + if( s == o ) + return true; + if( s != null ) + return s.equiv(o); + else + return (o instanceof Sequential || o instanceof List) && RT.seq(o) == null; } diff --git a/src/jvm/clojure/lang/PersistentList.java b/src/jvm/clojure/lang/PersistentList.java index d63e80db..9b446e96 100644 --- a/src/jvm/clojure/lang/PersistentList.java +++ b/src/jvm/clojure/lang/PersistentList.java @@ -120,7 +120,7 @@ public Object reduce(IFn f, Object start) throws Exception{ } public boolean equals(Object o) { - return (o instanceof Sequential || o instanceof List) && RT.count(o) == 0; + return (o instanceof Sequential || o instanceof List) && RT.seq(o) == null; } public boolean equiv(Object o){ |