For more "surprising" behaviour: (= #".*" #".*")
Sent from my iPhone On 11 Dec 2012, at 13:32, "Jim foo.bar" <jimpil1...@gmail.com> wrote: > If you're looking for some truly unintuitive equality behavior check this > out: > > user=> (def pred (Boolean. false)) ;;not a primitive but an object > #'user/pred > user=> (= pred false) > true > user=> (when pred (println "I really shouldn't print")) > I really shouldn't print > nil > > > Jim > > > On 11/12/12 13:19, Jim foo.bar wrote: >> From the docs: >> >>> 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. >> >> hope that helps... >> >> Jim >> >> >> >> On 11/12/12 13:17, Jim foo.bar wrote: >>> I disagree... >>> One of the nice things about clojrue is that, at tis hear, lies the 'equiv' >>> operator which is basically the 'egal' fn as defined by Baker [1993] [Equal >>> rights for functional objects or the mroe things change the more they stay >>> the same]. When using '=' with data-structures you are essentially >>> comparing values and not types. >>> >>> To come back to your example, both are sequential seqs that contain the >>> same values in the same order. Why shouldn't they be equal? Clojure >>> would not be the language we all love, if they weren't equal... >>> >>> Jim >>> >>> >>> On 03/10/12 06:24, Larry Travis wrote: >>>> What is the rationale for this? >>>> >>>> user> (= [1 2 3 4] '(1 2 3 4)) >>>> true >>>> >>>> I was quite surprised when this turned out to be the cause of a bug in a >>>> function I am constructing. Vectors and lists differ so substantially in >>>> their implementation and in their behavior that a vector and a list should >>>> not be considered "equal" just because they contain the same elements in >>>> the same order. >>>> >>>> --Larry > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@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+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en