PlQueryVariables Class

SWI-Prolog SbsSW.SwiPlCs

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++
public class PlQueryVariables
Public Class PlQueryVariables
public ref class PlQueryVariables
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 attempt to free resources and perform other cleanup operations before the Object 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

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

Assembly: SwiPlCs (Module: SwiPlCs) Version: 1.1.60301.0 (1.1.60301.0)