Re: Making a new definition of Equal work with lists as well
- To: mathgroup at smc.vnet.net
- Subject: [mg63387] Re: Making a new definition of Equal work with lists as well
- From: "dan.bernstein at gmail.com" <dan.bernstein at gmail.com>
- Date: Wed, 28 Dec 2005 03:55:43 -0500 (EST)
- References: <dor2jc$alo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thank you, Bill and Jean-Marc, for your replies. I'm afraid I didn't give a sufficiently general example in my question. What I would like to do is to be able to get True/False results for expressions as general as {CL[2,3], 5, {CL[4,5], CL[2,2]}, x} == {CL[2,3], 8, {CL[6,7], CL[9,9]}, y} that is, lists containing both CLs and other elements, and nested lists etc. Making Equal listable wouldn't work because I would then get also a list (of booleans) as a result. I think defining Equal for CL[a_, b_] could have "just worked" if Equal for lists was internally defined to AND the Equal of all matching pairs, something like Equal[j_ListQ, k_ListQ]:=If[Length[j]!=Length[k], False, And@@Table[Equal[j[[i]], k[[i]]], {i, 1, Length[j]}] And I guess I could re-define it this way, but I wonder what the built-in definition is, and what I stand to lose by overriding it like that. Thanks again, -- Dan
- Follow-Ups:
- Re: Re: Making a new definition of Equal work with lists as well
- From: Sseziwa Mukasa <mukasa@jeol.com>
- Re: Re: Making a new definition of Equal work with lists as well