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

• To: mathgroup at smc.vnet.net
• Subject: [mg12719] Re: [mg12662] Union[{0},{0.}] = {0,0.}?
• From: "Tomas Gargz" <tgarza at mail.internet.com.mx>
• Date: Wed, 3 Jun 1998 02:21:08 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Chris Farr 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.}] ÿalse
>How can I get around this?  The following doesn't help either.
>Union[{ N },{0.}] ÿ0,0.}
>Any ides out there?

Chris:
For one thing, 0 and 0. are distinct elements, so Mathematica is giving
Outÿnteger
Outÿeal

Now. N will not give 0. as you might like it to. It produces a real,
ÿowever, for any nonzero number.  You could get round the problem by
ÿransforming every real 0. to an integer 0 in the list you are
operating ÿpon with Union (or viceversa).

If your list is b, say,

In:ûÿ0},{0.}};

then

In:ÿ
Union[b/.{x_}->If[xð.,ToExpression[StringTake[ToString[0.], 1]]]]
Outÿ0}

I hope I did understand your problem.

Tomas Garza
Mexico City

```

• Prev by Date: Problem with Expand[Expr, Trig ->True]
• Next by Date: Re: How to get PostScript file in text mode.Path: monon.wolfram.com!paulh
• Previous by thread: Re: Union[{0},{0.}] = {0,0.}?
• Next by thread: Re: Union[{0},{0.}] = {0,0.}?