Re: check identity of lists

*To*: mathgroup at yoda.physics.unc.edu*Subject*: Re: check identity of lists*From*: bert at netcom.com (Roberto Sierra)*Date*: Sat, 28 Aug 93 02:30:22 -0700

"Tone Dieckmann" <TONE at econ.uni-mannheim.de> wrote: > Hi guys! > I want to check whether the outputs of two functions, which are both > lists, are identical. Now look at this: > In[1] := {True, True} == {True, True} > Out[1] = True (this is what I want) > But: > In[2] := Blabla[x] > Out[2] = {True, True} > In[3] := Whatever[y] > Out[3] = {True, True} > In[4] := %2 == %3 > Out[4] = {True, True} == {True, True} (why not just say "True"?) > In[5] := %2 === %3 > Out[5] = False ??? > In[6] := Evaluate[%2] == Evaluate[%3] > Out[6] = {True, True} == {True, True} (hopeless!) > Has anyone got any idea why this happens? > Thanks for any help. I can't give you a definitive answer as to why the above is happening, but I suspect that there's something wrong with your functions and that one of the lists is not *actually* {True,True}, but contains something screwy when closely examined. I tried to reproduce your results under MMA 2.03 for the Macintosh, and couldn't make the problem happen. I don't have the most up-to-date version (it's possible that what you're seeing only occurs in newer versions). In[1] := {True,True} == {True,True} Out[1] = True In[2] := BlahBlah[item_] := {True,True}; In[3] := Whatever[item_] := {True,True}; In[4] := BlahBlah[x] Out[4] = {True, True} In[5] := Whatever[y] Out[5] = {True, True} In[6] := %4 == %5 Out[6] = True (*CORRECT!!*) In[7] := %4 === %5 Out[7] = True (*CORRECT!!*) OK. I tried again, this time with the two functions actually *doing* something -- same results. In[8] := BlahBlah[item_] := {Head[item]==Symbol,AtomQ[item]}; In[9] := Whatever[item_] := {Length[item]==0,Sin[2 Pi] == 0}; In[10] := BlahBlah[x] Out[10] = {True, True} In[11] := Whatever[y] Out[11] = {True, True} In[12] := %10 == %11 Out[12] = True (*Correct again!!*) In[13] := %10 === %11 Out[13] = True (*Correct again!!*) The only way I could generate results which looked like what you were seeing was to substitute "True" for True in one of the lists, which prints out the same way as True, but is, of course, not equal to it. In[14] := BlahBlah[item_] := {True, True}; In[15] := Whatever[item_] := {True, "True"}; In[16] := BlahBlah[x] Out[16] = {True, True} In[17] := Whatever[y] Out[17] = {True, True} In[18] := %16 == %17 Out[18] = {True, True} == {True, True} (*Correct, but looks strange*) In[19] := %16 === %17 Out[19] = False (*Correct, but sure looks funny*) I would suggest that you examine the workings of your functions closely, you may be able to figure out what is happening. If it still stumps you, post your functions to the group. \\|// | "Due to the earthquake in the area you - - | are calling, your call cannot be o o | completed." -- N.E. Telephone, 10/89 J roberto sierra | O tempered microdesigns | NOTICE: \_/ san francisco, calif. | All the ideas and opinions expressed bert at netcom.com | herein are not those of the author.

**When do we get common subexpression elemination in Mma ?**

**Re: Mma Notebook to "PDEs with Mathematica (Dimitri Vvedensky)"**

**Re: check identity of lists**

**Literature Survey Notebook**