Beispiel #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))));
 }
Beispiel #2
0
 public static MList <T> List(T head, MList <T> tail) => new ListImpl(head, tail);
Beispiel #3
0
 public ListImpl(T head, MList <T> tail)
 {
     _head = head;
     _tail = tail;
 }
Beispiel #4
0
 public int GetHashCode(MList <T> mlist)
 {
     return(mlist.Match(
                empty: () => typeof(T).GetHashCode(),
                list:  (x, xs) => x.GetHashCode() + 31 * GetHashCode(xs)));
 }