MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Making a new definition of Equal work with lists as well

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63368] Re: Making a new definition of Equal work with lists as well
  • From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 27 Dec 2005 04:42:38 -0500 (EST)
  • Organization: The Open University, Milton Keynes, U.K.
  • References: <doohbr$kua$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Dan Bernstein" <dan.bernstein at gmail.com> a écrit dans le message de news: 
doohbr$kua$1 at smc.vnet.net...
| Hi,
|
| I have defined
| Equal[a_CL,b_CL] := a[[1]]-a[[2]] == b[[1]]-b[[2]]
| and then
| CL[2,3] == CL[4,5]
| CL[2,3] == CL[2,4]
| evaluate to True and False respectively, as expected. However,
| {CL[2,3]} == {CL[4,5]}
| just stays in that form.
|
| What should I do to make list equality use my "CL equality"?
|
| Thanks in advance,
| -- Dan Bernstein
|

Hi Dan,

A quick way is to use alternative patterns as in

In[1]:=
Unprotect[Equal];
((a_CL) | {a_CL}) == ((b_CL) | {b_CL}) :=
  a[[1]] - a[[2]] == b[[1]] - b[[2]]
Protect[Equal];

In[4]:=
CL[2, 3] == CL[4, 5]
CL[2, 3] == CL[2, 4]

Out[4]= True
Out[5]= False

In[6]:=
{CL[2, 3]} == {CL[4, 5]}
{CL[2, 3]} == {CL[2, 4]}

Out[6]= True
Out[7]= False

In[8]:=
CL[2, 3] == {CL[4, 5]}
{CL[2, 3]} == CL[2, 4]

Out[8]= True
Out[9]= False

Best regards,
/J.M. 



  • Prev by Date: Re: Re: Questions regarding MatrixExp, and its usage
  • Next by Date: Re: Making a new definition of Equal work with lists as well
  • Previous by thread: Making a new definition of Equal work with lists as well
  • Next by thread: Re: Making a new definition of Equal work with lists as well