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)); }
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 static IRoseTree <N, L1> SelectLeaf <N, L, L1>( this IRoseTree <N, L> source, Func <L, L1> selector) { return(source.SelectBoth(n => n, selector)); }
public void SelectBothObeysIdentityLaw(IRoseTree <int, string> t) { Assert.Equal(t, t.SelectBoth(Id, Id)); }
public static IRoseTree <N1, L> SelectNode <N, N1, L>( this IRoseTree <N, L> source, Func <N, N1> selector) { return(source.SelectBoth(selector, l => l)); }