Beispiel #1
0
        public void MapBothCompositionLawHolds(IRoseTree <int, string> t)
        {
            char f(bool b) => b ? 'T' : 'F';
            bool g(int x) => x % 2 == 0;
            bool h(int x) => x % 2 == 0;
            int i(string s) => s.Length;

            Assert.Equal(
                t.BiMap(x => f(g(x)), y => h(i(y))),
                t.BiMap(g, i).BiMap(f, h));
        }
Beispiel #2
0
        public void ConsistencyLawHolds(IRoseTree <int, string> t)
        {
            DateTime f(int i) => new DateTime(i);
            bool g(string s) => string.IsNullOrWhiteSpace(s);

            Assert.Equal(t.BiMap(f, g), t.MapLeaf(g).MapNode(f));
            Assert.Equal(
                t.MapNode(f).MapLeaf(g),
                t.MapLeaf(g).MapNode(f));
        }
Beispiel #3
0
 public static IRoseTree <N, L1> MapLeaf <N, L, L1>(
     this IRoseTree <N, L> source,
     Func <L, L1> func)
 => source.BiMap(n => n, func);
Beispiel #4
0
 public static IRoseTree <N1, L> MapNode <N, N1, L>(
     this IRoseTree <N, L> source,
     Func <N, N1> func)
 => source.BiMap(func, l => l);
Beispiel #5
0
 public void MapBothObeysIdentityLaw(IRoseTree <int, string> t)
 {
     Assert.Equal(t, t.BiMap(Id, Id));
 }