[Date Index]
[Thread Index]
[Author Index]
Re: equaltity of lists
*To*: mathgroup at smc.vnet.net
*Subject*: [mg19089] Re: [mg19036] equaltity of lists
*From*: "Tomas Garza" <tgarza at mail.internet.com.mx>
*Date*: Thu, 5 Aug 1999 01:35:09 -0400
*Sender*: owner-wri-mathgroup at wolfram.com
Drago Ganic [drago.ganic at in2.hr] wrote:
> Why don't I get an answer (False) when I ask Mathematica
>
> {a,b}=={b,a}
>
> like the one I get with
>
> {1,2}=={2,1}
> False
Cf. the definition of Equal in The Book or in the Help Browser:
lhs == rhs returns True if lhs and rhs are identical.
lhs == rhs is used to represent a symbolic equation, to be manipulated using
functions like Solve.
Clearly, a symbolic equation needs to know something about the symbols
involved. If a and b have not been assigned values, then Mathematica cannot
answer. See what happens, e.g.,
In[1]:=
a = b;
{a, b} == {b, a}
Out[2]=
True
In[3]:=
a = 1; b = 2;
{a, b} == {b, a}
Out[4]=
False
However,
lhs === rhs (SameQ) yields True if the expression lhs is identical to rhs,
and yields False otherwise.
Then, even if a and b have not been assigned any values, expression {a, b}
is clearly not identical to expression {b, a}.
In[5]:=
Clear[a, b];
{a, b} === {b, a}
Out[6]=
False
In[7]:=
{a, b} == {b, a}
Out[7]=
{a, b} == {b, a}
SameQ[] will always give you an answer, whereas Equal[] won't.
Tomas Garza
Mexico City
Prev by Date:
**Automatic grouping of animation cells**
Next by Date:
**Re: equaltity of lists**
Previous by thread:
**Re: equaltity of lists**
Next by thread:
**Re: equaltity of lists**
| |