Example #1
0
        public static LispList <T> Reverse(LispList <T> list)
        {
            LispList <T> rest = null;

            for (; list != null; list = list.tail)
            {
                rest = rest.Cons(list.element);
            }
            return(rest);
        }
Example #2
0
        private LispList <Pair <K, V> > Remove(LispList <Pair <K, V> > from, K key)
        {
            if (from == null)
            {
                return(null);
            }
            if (key.Equals(from.Head.Key))
            {
                return(from.Tail);
            }
            LispList <Pair <K, V> > tail = Remove(from.Tail, key);

            return(tail == from.Tail ? from : tail.Cons(from.Head));
        }
Example #3
0
 public static LispList <T> Cons <T> (this LispList <T> rest, T elem)
 {
     return(LispList <T> .Cons(elem, rest));
 }