Ejemplo n.º 1
0
 public static DataType Cons(T x, DataType ts)
 {
     if (IsEmpty(ts))
     {
         return(new One(x, RList <Tuple <T, T> > .Empty));
     }
     if (ts is Zero zero)
     {
         return(new One(x, zero.RList));
     }
     if (ts is One one)
     {
         return(new Zero(RList <Tuple <T, T> > .Cons(new Tuple <T, T>(x, one.Alpha), one.RList)));
     }
     throw new ArgumentException("must be null, Zero or One", nameof(ts));
 }