Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 3
0
 internal FList <T> Cons(T elem, FList <T> next)
 {
     return(new FList <T>(elem, next));
 }
Esempio n. 4
0
 internal FList(T elem, FList <T> next)
 {
     this.elem = elem;
     this.next = next;
 }