Example #1
0
        internal bool Find(T x)
        {
            FList <T> curr = this;

            while (curr != Empty)
            {
                if (curr.elem.Equals(x))
                {
                    return(true);
                }
                curr = curr.next;
            }
            return(false);
        }
Example #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("< ");
            if (this != Empty)
            {
                sb.Append(this.elem);
                FList <T> curr = this.next;
                while (curr != Empty)
                {
                    sb.Append(", " + curr.elem.ToString());
                    curr = curr.next;
                }
                sb.Append(" >");
            }
            return(sb.ToString());
        }
Example #3
0
 internal FList <T> Cons(T elem, FList <T> next)
 {
     return(new FList <T>(elem, next));
 }
Example #4
0
 internal FList(T elem, FList <T> next)
 {
     this.elem = elem;
     this.next = next;
 }