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); }
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; } }
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)))); }
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; }
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); }
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."); } }
public new static CodeList Create(XElement xCodeList) { return(new CodeList( CodeTermList.Create(xCodeList.Element(CodeTermList.ElementName)), CodeTerm.Create(xCodeList.Element(CodeTerm.ElementName)))); }
public CodeList() { m_head = new CodeTermList(new List <CodeTerm>()); m_tail = new CodeCompoundTerm(CodeFunctor.NilFunctor); }