Here is the following issue I am trying to solve. Finding the set of distinct element from the following sequence:
var l = new List<double>() { 0, 0 + 1e-7, 1 - 1e-7, 1 };
In my case I consider that two values are equals if:
public class DistanceComparer : IEqualityComparer<double>
{
public static IEqualityComparer<double> Default { get; } = new DistanceComparer();
public bool Equals(double x, double y)
{
return Math.Abs(x - y) < 1e-6;
}
public int GetHashCode(double obj) => throw new NotImplementedException();
}
Is there a way for me to re-use LINQ or any other existing framework to compute the list of distinct values ?