示例#1
0
文件: Cons.cs 项目: in-op/lambda-chop
        public Cons <T> Remove(T item)
        {
            Stack <T> acc  = new Stack <T>();
            Cons <T>  curr = this;

            while (!curr.IsEmpty)
            {
                if (EqualityComparer <T> .Default.Equals(curr.Head, item))
                {
                    while (acc.Count != 0)
                    {
                        curr = new Cons <T>(curr.Tail.Length + 1, acc.Pop(), curr.Tail);
                    }
                    return(curr);
                }

                acc.Push(curr.Head);
                curr = curr.Tail;
            }
            return(this);
        }
示例#2
0
文件: Cons.cs 项目: in-op/lambda-chop
 private Cons(int length, T head, Cons <T> tail)
 {
     Length = length;
     Head   = head;
     Tail   = tail;
 }