--Larry
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
It is surprising at first, but since vectors are used so commonly in Clojure instead of lists to represent literal sequential collections of data, it turns out to be extremely convenient to be able to compare it for equality against sequential collections generated as lists or lazy sequences. Basically, all those things are just flat, linear collections, and what we really care about from an equality standpoint is whether the collections have the same elements in the same order. Clojure similarly considers different types of maps (hash-maps, array-maps, sorted-maps) to be equal if the associations are the same. Ditto for hash-sets and sorted-sets.
It is surprising at first, but since vectors are used so commonly in Clojure instead of lists to represent literal sequential collections of data, it turns out to be extremely convenient to be able to compare it for equality against sequential collections generated as lists or lazy sequences. Basically, all those things are just flat, linear collections, and what we really care about from an equality standpoint is whether the collections have the same elements in the same order. Clojure similarly considers different types of maps (hash-maps, array-maps, sorted-maps) to be equal if the associations are the same. Ditto for hash-sets and sorted-sets.
Out of curiosity, if we want to check if two collections has the same structure/type and elements, namely if I want(my-equal [1 2 3 4 '(5)] [1 2 3 4 [5]]) => false
(my-equal [1 2 3 4 [5]] [1 2 3 4 [5]]) => true
Is there any convenient way to do that?
Equality. Returns true if x equals y, false if not. Same as
Java x.equals(y) except it also works for nil, and compares
numbers and collections in a type-independent manner. Clojure's immutable data
structures define equals() (and thus =) as a value, not an identity,
comparison.
Hi,
Equality is never subjective. There maybe different equality relations defined. In most cases (integer) one os well served by intuition.
In other cases (clojure's =) the definition may not be intuitive, but never subjective.
Great paper btw!