예제 #1
0
        public void SelectBothCompositionLawHolds(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.SelectBoth(x => f(g(x)), y => h(i(y))),
                t.SelectBoth(g, i).SelectBoth(f, h));
        }
예제 #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.SelectBoth(f, g), t.SelectLeaf(g).SelectNode(f));
            Assert.Equal(
                t.SelectNode(f).SelectLeaf(g),
                t.SelectLeaf(g).SelectNode(f));
        }
예제 #3
0
 public static IRoseTree <N, L1> SelectLeaf <N, L, L1>(
     this IRoseTree <N, L> source,
     Func <L, L1> selector)
 {
     return(source.SelectBoth(n => n, selector));
 }
예제 #4
0
 public void SelectBothObeysIdentityLaw(IRoseTree <int, string> t)
 {
     Assert.Equal(t, t.SelectBoth(Id, Id));
 }
예제 #5
0
 public static IRoseTree <N1, L> SelectNode <N, N1, L>(
     this IRoseTree <N, L> source,
     Func <N, N1> selector)
 {
     return(source.SelectBoth(selector, l => l));
 }