diff options
author | Eduardo Julian | 2016-12-01 15:52:51 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-01 15:52:51 -0400 |
commit | ac68b9bdf7fb8195e8c3862285efa19e59505c2a (patch) | |
tree | 113811a638e9d53eb20b5fc83c5670a14eff9dbf /stdlib/source | |
parent | 4528aee1d700ba0ac611fb07faf4c5a8c7e0b9ad (diff) |
- Improved the implementation of vector equality.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/struct/vector.lux | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/stdlib/source/lux/data/struct/vector.lux b/stdlib/source/lux/data/struct/vector.lux index bb31063a4..4b8fb4bf3 100644 --- a/stdlib/source/lux/data/struct/vector.lux +++ b/stdlib/source/lux/data/struct/vector.lux @@ -352,9 +352,25 @@ (wrap (list (` (from-list (list (~@ elems))))))) ## [Structures] +(struct: #export (Eq<Node> Eq<a>) (All [a] (-> (Eq a) (Eq (Node a)))) + (def: (= v1 v2) + (case [v1 v2] + [(#Base b1) (#Base b2)] + (:: (array;Eq<Array> Eq<a>) = b1 b2) + + [(#Hierarchy h1) (#Hierarchy h2)] + (:: (array;Eq<Array> (Eq<Node> Eq<a>)) = h1 h2) + ))) + (struct: #export (Eq<Vector> Eq<a>) (All [a] (-> (Eq a) (Eq (Vector a)))) (def: (= v1 v2) - (:: (list;Eq<List> Eq<a>) = (to-list v1) (to-list v2)))) + (and (=+ (get@ #size v1) (get@ #size v2)) + (:: (Eq<Node> Eq<a>) = + (#Base (get@ #tail v1)) + (#Base (get@ #tail v2))) + (:: (Eq<Node> Eq<a>) = + (#Hierarchy (get@ #root v1)) + (#Hierarchy (get@ #root v2)))))) (struct: _ (Fold Node) (def: (fold f init xs) |