Example #1
0
        public void SecondFunctorLawHoldsForSelectLeaf(IRoseTree <int, string> t)
        {
            bool f(int x) => x % 2 == 0;
            int g(string s) => s.Length;

            Assert.Equal(
                t.SelectLeaf(x => f(g(x))),
                t.SelectLeaf(g).SelectLeaf(f));
        }
Example #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));
        }
Example #3
0
 public void SelectLeafObeysFirstFunctorLaw(IRoseTree <int, string> t)
 {
     Assert.Equal(t, t.SelectLeaf(Id));
 }
Example #4
0
 // Functor
 public static IRoseTree <N, L1> Select <N, L, L1>(
     this IRoseTree <N, L> source,
     Func <L, L1> selector)
 {
     return(source.SelectLeaf(selector));
 }