示例#1
0
 public static A FoldLeft <A, B>(Func <A, B, A> f, A accum, IHeadTailList <B> list)
 {
     if (list.IsEmpty())
     {
         return(accum);
     }
     return(FoldLeft(f, f(accum, list.Head()), list.Tail()));
 }
示例#2
0
 public static A FoldRight <A, B>(Func <B, A, A> f, A seed, IHeadTailList <B> list)
 {
     if (list.IsEmpty())
     {
         return(seed);
     }
     return(f(list.Head(), FoldRight(f, seed, list.Tail())));
 }