MathGroup Archive 1998

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

Search the Archive

Re: Union[{0},{0.}] = {0,0.}?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg12717] Re: Union[{0},{0.}] = {0,0.}?
  • From: dreissNOSPAM at nospam.earthlink.net (David Reiss)
  • Date: Wed, 3 Jun 1998 02:21:06 -0400
  • Organization: EarthLink Network, Inc.
  • References: <6kvpko$7hl@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <6kvpko$7hl at smc.vnet.net>, "Chris Farr" <farr at brown.edu>
wrote:

> Union[{0},{0.}] = {0,0.}.
> 
> Why?
> 
> I would like the above to return only {0}.
> 
> The root of the problem is that Mathematica thinks they are the same:
> 
> SameQ[{0},{0.}] = False
> 
> How can I get around this?  The following doesn't help either.
> 
> Union[{ N[0] },{0.}] = {0,0.}
> 
> Any ideas out there?


Here is one possibility using the SameTest option to Union:

In[1]:=
Union[{0},{0.}] 

Out[1]=
{0,0.}

In[2]:=
Union[{0},{0.},SameTest->(N[#1]==N[#2]&)] 

Out[2]=
{0}

-- 
David Reiss
dreissNOSPAM at nospam.earthlink.net
http://home.earthlink.net/~dreiss
To send personal email, remove the words  "nospam" and "NOSPAM" from the
email address


  • Prev by Date: Greek letter epsilon / varepsilon
  • Next by Date: Re: Using a palette as an interface
  • Previous by thread: Re: Union[{0},{0.}] = {0,0.}?
  • Next by thread: RE: Union[{0},{0.}] = {0,0.}?