PlQueryVariables Class

SbsSW.SwiPlCs

Copy image CopyHover image
Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog PlQueryVariables Class
SwiPlCs interfaceSbsSW.SwiPlCsPlQueryVariables

Represents the set variables of a Query if it was created from a string.

This class is also used to represent the results of a PlQuery after ToList()()()() or SolutionVariables was called.

Declaration Syntax
C# Visual Basic Visual C++ F#
public class PlQueryVariables
Public Class PlQueryVariables
public ref class PlQueryVariables
type PlQueryVariables =  class end
Members
All Members Constructors Methods Properties



Icon Member Description
PlQueryVariables()()()()
Initializes a new instance of the PlQueryVariables class

Count
Returns the number of elements in the sequence. (Defined by Enumerable of List<PlQueryVar>.)

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Finalize()()()()
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
GetHashCode()()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()()
Gets the type of the current instance.
(Inherited from Object.)
Item[([( String])])
Gets the PlTerm of the given variable name or throw an ArgumentException.

MemberwiseClone()()()()
Creates a shallow copy of the current Object.
(Inherited from Object.)
ToString()()()()
Returns a string that represents the current object.
(Inherited from Object.)
Examples

This sample shows both Variables is used to unify the variables of two nested queries and the result

  Copy imageCopy
public void TestCompoundNestedQueryWithVariables3()
{
    string[] refValuesInner = { "_gap_abc1", "_gap_abc2", "a_gap_bc1", "a_gap_bc2", "ab_gap_c1", "ab_gap_c2", "abc_gap_1", "abc_gap_2" };
    int innerIdx = 0;
    using (new PlFrame())
    {
        try
        {
            var outerQuery = new PlQuery("append(A,B,C), atomic_list_concat(A, A1), atomic_list_concat(B, B1)");
            outerQuery.Variables["C"].Unify(new PlTerm("[a,b,c]"));
            var innerQuery = new PlQuery("member(Count, [1,2]), atomic_list_concat([X, Y, Z, Count], ATOM)");
            innerQuery.Variables["X"].Unify(outerQuery.Variables["A1"]);
            innerQuery.Variables["Y"].Unify("_gap_");
            innerQuery.Variables["Z"].Unify(outerQuery.Variables["B1"]);
            foreach (PlQueryVariables vars in outerQuery.SolutionVariables)
            {
                var results = from n in innerQuery.ToList() 
                    select new { L = n["ATOM"].ToString(), X = n["X"].ToString(), Y = n["Z"].ToString() };
                foreach (var v in results)
                {
                    Assert.AreEqual(refValuesInner[innerIdx++], v.L);
                }
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Trace.WriteLine(ex.Message);
            Assert.IsFalse(true);
        }
    }
}
Inheritance Hierarchy
Object
PlQueryVariables
See Also

Assembly: SwiPlCs (Module: SwiPlCs.dll) Version: 1.1.60605.0 (1.1.60605.0)