Пример #1
0
        /*
         * Returns null if the query doesn't succeed, and a binding (which will be a Symbol or a Structure) if it does. If the variable on the left hand
         * side of the colon expression doesn't appear in the query, the Symbol will be a gensym.
         * If the query isn't a colon expression, will return the bool true to indicate query success, and null to indicate failure.
         */
        public object SolveForParsed(string query)
        {
            object parsedQuery = ISOPrologReader.Read(query);

            if (parsedQuery is Structure colonExpression && colonExpression.IsFunctor(Symbol.Colon, 2))
            {
                // The parsedQuery is a colon expression. Use KB.solveFor to generate a binding.
                return(KB.SolveFor((LogicVariable)colonExpression.Argument(0), colonExpression.Argument(1), null, false));
            }