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 2007

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

Search the Archive

Re: programming problem about elements taken

  • To: mathgroup at
  • Subject: [mg72497] Re: programming problem about elements taken
  • From: "Ray Koopman" <koopman at>
  • Date: Wed, 3 Jan 2007 01:03:03 -0500 (EST)
  • References: <><en82hd$6or$>

Andrzej Kozlowski wrote:
> Consider this list of 5 numbers:
>   ls = Sort[Table[Random[], {5}]]
>   {0.165874, 0.256035, 0.556211, 0.811305, 0.865799}
> Suppose we take epsilon = 0.3 and identify the numbers distant by
> less than that from one another. Then
> Union[ls, SameTest -> (Abs[#1 - #2] < 0.3 &)]
>   {0.165874, 0.556211, 0.865799}
> gives us just three numbers.
> [...]
> Note that when two numbers are identified it is the smaller one that
> is kept.
> [...]

Is this just an observation, or official-but-not-publicly-documented?
The arguments to SameTest seem always to be reverse-ordered (i.e.,
#2 >= #1), even when the input list is unsorted, and the sequence of
argument pairs seems to be the same regardless of whether the input
list is sorted or unsorted. Can we conclude that Union sorts the input
list before using SameTest, and that when SameTest returns True it is
the second argument that is kept?

  • Prev by Date: default format for importing data into mathematica
  • Next by Date: Re: Combining surfaces
  • Previous by thread: Re: programming problem about elements taken
  • Next by thread: Re: Re: programming problem about elements taken