Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Union question

  • To: mathgroup at
  • Subject: [mg13922] Re: [mg13889] Union question
  • From: BobHanlon at
  • Date: Mon, 7 Sep 1998 01:22:47 -0400
  • Sender: owner-wri-mathgroup at


See on-line help for Union and SameTest.

data = Table[Random[], {10}]


closeEnough[x_, y_] := Abs[x-y] < 10^-1 (* In your case use 10^-12 *)

Union[data, SameTest->closeEnough]


Bob Hanlon

In a message dated 9/6/98 7:18:34 AM, gas2y at

>I'm trying to take a very long list of real numbers and use the Union
>function on it to remove duplicates.  The problem is that the real
>numbers that I consider to be the same, differ after their 12th decimal
>place.  I have tried without sucess to use N and SetAccuracy functions
>on each element of the list Before using the Union Function, but to no
>Avail.  Is there any quick way to take a long list, and remove
>duplicate elements by comparing only the first n significant digets of
>each element.

  • Prev by Date: Re: Assigning a list to coefficients
  • Next by Date: Re: how can I save only the text of a notebook?
  • Previous by thread: Union question
  • Next by thread: Simple but difficult integral ? Help ..!??