Re: Q: Union and SameTest Option

• To: mathgroup at smc.vnet.net
• Subject: [mg16141] Re: [mg16016] Q: Union and SameTest Option
• From: "Tomas Garza" <tgarza at mail.internet.com.mx>
• Date: Sat, 27 Feb 1999 03:23:09 -0500
• Sender: owner-wri-mathgroup at wolfram.com

```Clemens Frey wrote:

> Can anybody explain to me what's going on here ?
>
> In[270]:=
> Union[ {{a,b,1},{a,c,1},{x,y,2},{a,b,2}},
>        SameTest->(#1[[2]]===#2[[2]]&) ]
> Out[270]=
> {{a,b,1},{a,c,1},{x,y,2}}
>
> is ok since the first and the last list element have the same second
> component. But what is wrong here now ?
>
> In[272]:=
> Union[ {{a,b,1},{a,c,1},{x,y,2},{a,b,2}},
>        SameTest->(#1[[3]]===#2[[3]]&) ]
> Out[272]=
> {{a,b,1},{a,b,2},{a,c,1},{x,y,2}}

Clemens,

Most intriguing, and I would venture that there is a bug somewhere. In fact,
if you split your original list into two parts, perform the Union operation
on each of them, and finally perform a Union on the two results, you get the

In[1]:=
Union[Union[ {{a,b,1},{a,c,1}},SameTest->(#1[[3]]===#2[[3]]&)],
Union[ {{x,y,2},{a,b,2}},SameTest->(#1[[3]]===#2[[3]]&)]]
Out[1]=
{{a,b,1},{a,b,2}}

Tomas Garza
Mexico City

```

• Prev by Date: Re: Q: Union and SameTest Option
• Next by Date: Re: Re: Re: Re: Bug?
• Previous by thread: Re: Q: Union and SameTest Option
• Next by thread: Strange results from Integrate