Пример #1
0
        public static bool IsAssociative <MONOID, T>(T x, T y, T z, IEqualityComparer <T> comparer = null)
            where MONOID : struct, IMonoid <T>
        {
            comparer ??= EqualityComparer <T> .Default;

            return(comparer.Equals(Monoid.Concat <MONOID, T>(x, Monoid.Concat <MONOID, T>(y, z)),
                                   Monoid.Concat <MONOID, T>(Monoid.Concat <MONOID, T>(x, y), z)));
        }
Пример #2
0
        public static bool HasIdentity <MONOID, T>(T x, IEqualityComparer <T> comparer = null)
            where MONOID : struct, IMonoid <T>
        {
            comparer ??= EqualityComparer <T> .Default;

            return(comparer.Equals(Monoid.Concat <MONOID, T>(x, Monoid.Empty <MONOID, T>()), x) &&
                   comparer.Equals(Monoid.Concat <MONOID, T>(Monoid.Empty <MONOID, T>(), x), x));
        }