예제 #1
0
 public static TResult Cata <N, L, TResult>(
     this IRoseTree <N, L> tree,
     Func <N, IEnumerable <TResult>, TResult> node,
     Func <L, TResult> leaf)
 {
     return(tree.Accept(new CataVisitor <N, L, TResult>(node, leaf)));
 }
예제 #2
0
        public void MatchNode()
        {
            IRoseTree <string, int> tree =
                RoseTree.Node("foo",
                              new RoseLeaf <string, int>(42),
                              new RoseLeaf <string, int>(1337));
            int actual = tree.Accept(new MatchStringNodeVisitor());

            Assert.Equal(3, actual);
        }
예제 #3
0
 public static IChurchBoolean IsLeaf <N, L>(this IRoseTree <N, L> source)
 {
     return(source.Accept(new IsLeafVisitor <N, L>()));
 }