Re: Re: confused about == vs === in this equality
- To: mathgroup at smc.vnet.net
- Subject: [mg103775] Re: [mg103747] Re: confused about == vs === in this equality
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Mon, 5 Oct 2009 13:17:07 -0400 (EDT)
- References: <20091003104738.LCJ3I.416659.imail@eastrmwml34>
Apparently, at the bottom of that page I made an incorrect statement: Nasser just found an example where SameQ gives True while Equal evaluates to itself. I should post it in the <errata> section and then eventually correct it. Regards, Leonid On Mon, Oct 5, 2009 at 3:35 PM, Chris Degnen <degnen at cwgsy.net> wrote: > I refer you to Leonid's Mathematica introduction: > > http://www.mathprogramming-intro.org/book/node109.html > > > "Nasser Abbasi" <nma at 12000.org> asked: > > > > ?=== > > lhs===rhs yields True if the expression lhs is identical to rhs, and > > yields > > False otherwise. > > > > ?== > > lhs==rhs returns True if lhs and rhs are identical. > > > > But looking at this example: > > > > a = ComplexInfinity; > > If[a == ComplexInfinity, Print["YES"]] > > > > Expecting it would print "YES", but it does not. it just returns the > whole > > thing unevaluated? But > > > > If[a === ComplexInfinity, Print["YES"]] > > > > does return YES. > > > > I guess I am a little confused about the "expression" bit in the > > definition. > > > > So, when using the 3"=", it is looking at the _value_ of the expression, > > but > > when using the 2"=", it is looking at the expression _as it is_, i.e. > > without evaluating it? Is this the difference? I've always used the > 2"=" > > for equality, now I have to be more careful which to use. > > > > --Nasser > > > > >