[Date Index]
[Thread Index]
[Author Index]
Re: Making a new definition of Equal work with lists as well
*To*: mathgroup at smc.vnet.net
*Subject*: [mg63369] Re: Making a new definition of Equal work with lists as well
*From*: Bill Rowe <readnewsciv at earthlink.net>
*Date*: Tue, 27 Dec 2005 04:42:39 -0500 (EST)
*Sender*: owner-wri-mathgroup at wolfram.com
On 12/26/05 at 4:59 AM, dan.bernstein at gmail.com (Dan Bernstein)
wrote:
>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"?
There are two ways I can think of to accomplish this. First, you can use SetAttributes to give Equal the Listable attribute, i.e.,
SetAttributes[Equal, Listable]
then {CL[2,3]} == {CL[4,5]} will evaluate to {True}. But, making Equal Listable may have some undesired side effects on other usages of Equal I haven't considered. Modifying commonly used built-in functions in this manner is risky.
An alternative would be to add another definition for equal, i.e.,
Equal[{a_CL},{b_CL}]:= Equal[a,b]
Doing things this way prevents side effects since this definition only operates on lists with one element with head CL
--
To reply via email subtract one hundred and four
Prev by Date:
**Re: Making a new definition of Equal work with lists as well**
Next by Date:
**Re: Re: Questions regarding MatrixExp, and its usage**
Previous by thread:
**Re: 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**
| |