Пример #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            CodeTermList rhs = obj as CodeTermList;

            if (rhs == null)
            {
                return(false);
            }

            if (Count != rhs.Count)
            {
                return(false);
            }

            for (int idx = 0; idx < Count; ++idx)
            {
                if (this[idx] != rhs[idx])
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        public CodeList(IEnumerable <CodeTerm> head, CodeTerm tail)
        {
            if (head == null)
            {
                throw new ArgumentNullException("head");
            }
            if (tail == null)
            {
                throw new ArgumentNullException("tail");
            }

            if (tail.IsCodeList)
            {
                List <CodeTerm> headTerms = new List <CodeTerm>(head);
                headTerms.AddRange(tail.AsCodeList.Head);

                m_head = new CodeTermList(headTerms);
                m_tail = tail.AsCodeList.Tail;
            }
            else
            {
                m_head = new CodeTermList(new List <CodeTerm>(head));
                m_tail = tail;
            }
        }
Пример #3
0
        public new static CodeCompoundTerm Create(XElement xCodeCompoundTerm)
        {
            CodeFunctor codeFunctor = CodeFunctor.Create(xCodeCompoundTerm.Element(CodeFunctor.ElementName));

            if (codeFunctor.Arity == 0)
            {
                return(new CodeCompoundTerm(codeFunctor));
            }

            return(new CodeCompoundTerm(
                       codeFunctor,
                       CodeTermList.Create(xCodeCompoundTerm.Element(CodeTermList.ElementName))));
        }
Пример #4
0
        public CodeCompoundTerm(CodeFunctor functor)
        {
            if (functor == null)
            {
                throw new ArgumentNullException("functor");
            }

            if (functor.Arity != 0)
            {
                throw new ArgumentException("Functor with non-zero arity specified.");
            }

            m_functor  = functor;
            m_children = s_emptyList;
        }
Пример #5
0
        public bool Equals(CodeTermList other)
        {
            if (object.ReferenceEquals(other, null))
            {
                return(false);
            }

            if (Count != other.Count)
            {
                return(false);
            }

            for (int idx = 0; idx < Count; ++idx)
            {
                if (this[idx] != other[idx])
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #6
0
        public CodeCompoundTerm(CodeFunctor functor, IEnumerable <CodeTerm> children)
        {
            if (functor == null)
            {
                throw new ArgumentNullException("functor");
            }
            if (children == null)
            {
                throw new ArgumentNullException("children");
            }

            if (functor.Arity == 0)
            {
                throw new ArgumentException("Functor with zero arity specified.");
            }

            m_functor  = functor;
            m_children = new CodeTermList(new List <CodeTerm>(children));

            if (m_children.Count != m_functor.Arity)
            {
                throw new ArgumentException("Number of arguments does not match functor arity.");
            }
        }
Пример #7
0
 public new static CodeList Create(XElement xCodeList)
 {
     return(new CodeList(
                CodeTermList.Create(xCodeList.Element(CodeTermList.ElementName)),
                CodeTerm.Create(xCodeList.Element(CodeTerm.ElementName))));
 }
Пример #8
0
 public CodeList()
 {
     m_head = new CodeTermList(new List <CodeTerm>());
     m_tail = new CodeCompoundTerm(CodeFunctor.NilFunctor);
 }