MathGroup Archive 2005

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

Search the Archive

Re: SameTest in Union

  • To: mathgroup at
  • Subject: [mg61112] Re: [mg61106] SameTest in Union
  • From: curtis <gardyloo at>
  • Date: Tue, 11 Oct 2005 03:20:05 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

Hi, Jack,

   I always have to relearn SameTest stuff. In this case I had it all
along, but didn't notice that lst has a misplaced dot between the last
two elements (should be a comma). If that's changed, and you use

Union[lst, SameTest -> (#1 - #2 < 0.05 & )]

   then it should do what you want.


Jack Goldberg wrote:

>Hi Folks,
>I know there is a simple answer to this question but the help index  
>idoes not help!
>I have a list, something like this:
>lst = {1.1101, 1.11095, 1.11076, 1.09, 2.3523, 2.352. 2.35211}
>I want to remove from the list those entries which are near each  
>other but not identical, leaving only one representative for each of  
>these numbers.  One approach is to use  Union with the option   
>SameTest->???.   Here the same test might be that the difference  
>between entries is less than, say 10^(-2).   But I can't seem to get  
>SameTest to work.  So, what I want is
>Union[ lst, SameTest- > ?]
>so that  the union returns
>{1.1101,  2.35211}
>Here, I chose 2 representatives.  Any other choice is OK;   say,
>{1.11095,  2.352}
>is also satisfactory.
>There may be other ways to do this, but I thought of  Union  first.   
>Perhaps, Cases  or Select  might be better.  Any help is appreciated.

|  Curtis Osterhoudt              
|  gardyloo at                   
|  PGP Key ID: 0x235FDED1                               
|  Please avoid sending me Word or PowerPoint attachments. 

  • Prev by Date: Re: SameTest in Union
  • Next by Date: Re: SameTest in Union
  • Previous by thread: SameTest in Union
  • Next by thread: Re: SameTest in Union