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