コード例 #1
0
        public bool CompileProgram(IProgramUnifier program)
        {
            // The dependencies of the assignTo value indicate the parameters of this term
            var terms = _assignTo.Dependencies.ToArray();

            // Put the structure
            if (!program.GetStructure(_assignTo.UnificationKey, terms.Length, _target))
            {
                return(false);
            }

            // Put the variables
            foreach (var termVariable in terms)
            {
                if (program.HasVariable(termVariable))
                {
                    if (!program.UnifyValue(termVariable))
                    {
                        return(false);
                    }
                }
                else
                {
                    if (!program.UnifyVariable(termVariable))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #2
0
 public bool CompileProgram(IProgramUnifier program)
 {
     if (program.HasVariable(_variable))
     {
         return(program.GetValue(_variable, _argument));
     }
     else
     {
         return(program.GetVariable(_variable, _argument));
     }
 }