Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog
PlCall Method (predicate, args)
SwiPlCs interface ► SbsSW.SwiPlCs ► PlQuery ► PlCall(String, PlTermV)
Create a query where name defines the name of the predicate and av the argument vector.
The arity is deduced from av. The predicate is located in the Prolog module user.


Return true or false as the result of NextSolution() or throw an exception.

Create a PlQuery from the arguments, generates the first solution by NextSolution() and destroys the query.

This sample shows a query with a compound term as an argument.

public void PlCallQueryCompound_termv() { string[] mm = { "aa1", "aa2", "aa3" }; build_pred(); // create: test(comp(X,Y)) :- member(Z,[1,2,3]), atomic_list_concat([X,Z],Y). PlTerm var1 = PlTerm.PlVar(); PlTerm comp = PlTerm.PlCompound("comp", new PlTerm("aa"), var1); using (PlQuery q = new PlQuery("test", new PlTermV(comp))) { int i = 0; foreach (PlTermV s in q.Solutions) { Assert.AreEqual(mm[i++].ToString(), var1.ToString()); Assert.AreEqual(comp.ToString(), s[0].ToString()); } } }