Union and SameTest
Q: I want to apply to a list of real numbers in which many duplicates occur. However,
small differences between the numbers cause some of the duplicates to be retained instead
of discarded. Suppose the list is
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr2.gif]](inoutcgr2.gif)
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr4.gif]](inoutcgr4.gif)
My present method is to apply to the numbers.
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr6.gif]](inoutcgr6.gif)
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr7.gif]](inoutcgr7.gif)
Is there a better method?
Adam Strzebonski (adams@wolfram.com) answers: uses to decide which
elements should be considered equal. Here is a that does what you want:
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr11.gif]](inoutcgr11.gif)
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr12.gif]](inoutcgr12.gif)
![[Graphics:inoutcgr3.gif]](inoutcgr3.gif) ![[Graphics:inoutcgr13.gif]](inoutcgr13.gif)
|