# DeleteCases vs. DeleteDuplicates for removing points within a critical Euclidean distance

I'm attempting to remove all points in an array which are within a Euclidean distance "ThresDist" of one-another. Using the command:

DeleteDuplicates[List, EuclideanDistance[#1, #2] <= ThresDist &];


I can remove one point in a pair of points that fall within a distance "ThresDist" of one-another. However:

DeleteCases[List, EuclideanDistance[#1, #2] <= ThresDist  &];


Fails to work similarly. Is there something wrong with my approach?

Note : I made a typo earlier in writing DeleteCases, and also used a poor variable name. This was sloppy of me.

As for the actual question - how might I best accomplish my goal? I've searched through Mathematica's function directory, and I can't seem to find an appropriate way to prune not just a duplicate point, but all points that fall within a threshold distance of one-another?

• DeleteDCases is spelt incorrectly but assuming this is a typo. For DeleteCases you need to use a pattern and you will be parsing one argument to a function used as a pattern test or to a pattern condition Jul 18, 2013 at 1:40

You seem to be new around here so I am going to answer this, but others may close it as "a simple mistake."

• D is a reserved (System) Symbol; use d or dist etc. instead.

• DeleteDCases should be DeleteCases.

• DeleteCases looks at each element independently, not pairs of elements as does DeleteDuplicates (when using a custom equivalence function).

• DeleteCases requires a pattern, not a function, for the second argument.

Since you are making a number of mistakes I shall direct you to this massive omnibus collection of instructional resources:

Where can I find examples of good Mathematica programming practice?

In response to your updated question, specifically:

As for the actual question - how might I best accomplish my goal?