コード例 #1
0
ファイル: CodeTermList.cs プロジェクト: russlank/Prolog.NET
        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
ファイル: CodeList.cs プロジェクト: Year-2019-20/TaskFlow.NET
        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
ファイル: CodeTermList.cs プロジェクト: russlank/Prolog.NET
        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
ファイル: CodeList.cs プロジェクト: Year-2019-20/TaskFlow.NET
 public new static CodeList Create(XElement xCodeList)
 {
     return(new CodeList(
                CodeTermList.Create(xCodeList.Element(CodeTermList.ElementName)),
                CodeTerm.Create(xCodeList.Element(CodeTerm.ElementName))));
 }
コード例 #8
0
ファイル: CodeList.cs プロジェクト: Year-2019-20/TaskFlow.NET
 public CodeList()
 {
     m_head = new CodeTermList(new List <CodeTerm>());
     m_tail = new CodeCompoundTerm(CodeFunctor.NilFunctor);
 }