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)); }
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)); }
public static IRoseTree <N, L1> MapLeaf <N, L, L1>( this IRoseTree <N, L> source, Func <L, L1> func) => source.BiMap(n => n, func);
public static IRoseTree <N1, L> MapNode <N, N1, L>( this IRoseTree <N, L> source, Func <N, N1> func) => source.BiMap(func, l => l);
public void MapBothObeysIdentityLaw(IRoseTree <int, string> t) { Assert.Equal(t, t.BiMap(Id, Id)); }