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