Here is the following issue I am trying to solve. Computing the number of distinct elements from the following sequence within a tolerance:
var l = new List<double>() { 0, 0 + 1e-7, 0 + 2e-7, 1 - 1e-7, 1 };
The list is sorted, and all values are distinct (using the default equality comparer to compare values).
How can I count the number of unique values within a particular tolerance value:
static bool IsWithinTolerance(double x, double y)
{
return Math.Abs(x - y) < 1e-6;
}