Ejemplo n.º 1
0
 public bool Equals(MList <T> first, MList <T> second)
 {
     return(first.Match(
                empty: () => second.Match(
                    empty: () => true,
                    list:  (x, xs) => false),
                list:  (x, xs) => second.Match(
                    empty: () => false,
                    list:  (y, ys) => x.Equals(y) && Equals(xs, ys))));
 }
Ejemplo n.º 2
0
 public static MList <T> List(T head, MList <T> tail) => new ListImpl(head, tail);
Ejemplo n.º 3
0
 public ListImpl(T head, MList <T> tail)
 {
     _head = head;
     _tail = tail;
 }
Ejemplo n.º 4
0
 public int GetHashCode(MList <T> mlist)
 {
     return(mlist.Match(
                empty: () => typeof(T).GetHashCode(),
                list:  (x, xs) => x.GetHashCode() + 31 * GetHashCode(xs)));
 }