Re: Union using SameTest
- To: mathgroup at smc.vnet.net
- Subject: [mg61208] Re: [mg61195] Union using SameTest
- From: Andrzej Kozlowski <andrzej at yhc.att.ne.jp>
- Date: Wed, 12 Oct 2005 03:09:05 -0400 (EDT)
- References: <200510120542.BAA09279@smc.vnet.net>
- Reply-to: Andrzej Kozlowski <andrzej at akikoz.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 12 Oct 2005, at 14:42, Jack Goldberg wrote: > Hi Everyone, > > Thanks for all your responses. I am grateful and somewhat > mystified. The solutions > SameTest->(Abs[#1-#2]<10^-2&)] was the first thing I tried! It > didn't work for me - in fact it gave a strange error message - > something involving "heads in positions 1 and 2 must be the same". > This was the reason for my posting. Well, I tried it again and now > it works. At this point I believe that the error has to do with my > reusing certain names over and over with clearing them. But I am not > sure and since I can't reconstruct the error - I'm letting this > sleeping dog lie. > > Thanks again fellas! > > Jack > > I doubt that "the error has to do with your reusing certain names over and over with clearing them". Rather it is simply this: In[55]:= lst = {1.1101, 1.11095, 1.11076, 1.09, 2.3523, 2.352, 2.35211}; In[56]:= Union[lst, SameTest -> Abs[#1 - #2] < 10^(-2) & ] Union::"heads":"Heads Function and List at positions `2 and `1 are expected to be the same. Out[56]= Union[{1.1101, 1.11095, 1.11076, 1.09, 2.3523, 2.352, 2.35211}, SameTest -> Abs[#1 - #2] < 1/10^2 & ] while: In[57]:= Union[lst, SameTest -> (Abs[#1 - #2] < 10^(-2) & )] Out[57]= {1.09, 1.1101, 2.352} Note the parentheses. Andrzej Kozlowski Tokyo, Japan
- References:
- Union using SameTest
- From: Jack Goldberg <jackgoldberg@comcast.net>
- Union using SameTest