Пример #1
0
 public Shrub <T2> Map <T2>(Func <T, T2> f)
 {
     return(Match(
                l => Shrub <T2> .Node(l.Select(s => s.Map <T2>(f)).ToList())
                ,
                v => Shrub <T2> .Leaf(f(v))));
 }
Пример #2
0
 public static Shrub <T2> Collapse <T2>(Shrub <Shrub <T2> > input)
 {
     return(input.Match <Shrub <T2> >(
                l => Shrub <T2> .Node(l.Select(Collapse <T2>).ToList()),
                v => v.Match(Shrub <T2> .Node, Shrub <T2> .Leaf)
                ));
 }
Пример #3
0
 public Shrub <T2> MapI <T2>(List <int> p, Func <T, List <int>, T2> f)
 {
     return(Match(
                l => Shrub <T2> .Node(l.Select((s, i) => s.MapI <T2>(p.Append(i).ToList(), f)).ToList())
                ,
                v => Shrub <T2> .Leaf(f(v, p))));
 }