Beispiel #1
0
        public static void FoldMapTreeEnum(Tree <int> t)
        {
            var expected = t.Select(x => x * 2).ToList();
            var actual   = t.FoldMap(Monoid.ListAppend <int>(), x => new List <int> {
                x * 2
            });

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        public static void ListAppendMonoidTest()
        {
            var m = Monoid.ListAppend <int>();

            var xs = new List <int> {
            };

            Assert.Empty(m.Neutral);
            Assert.Equal(new int[] { 3, 4 }, m.Op(xs, new List <int> {
                3, 4
            }));

            Assert.Equal(new int[] { 3, 4 }, xs);

            xs = new List <int> {
            };

            Assert.Equal(new int[] { 3, 4 }, m.Op(new List <int> {
                3, 4
            }, xs));

            Assert.Empty(xs);
        }