Item Property (pos)

SWI-Prolog SbsSW.SwiPlCs

Swi-cs-pl - A CSharp class library to connect .NET languages with SWI-Prolog Item Property (pos)
SwiPlCs interfaceSbsSW.SwiPlCsPlTermItem[([( Int32])])

If PlTerm is compound and index is between 0 and Arity (including), the nth PlTerm is returned.

If pos is 0 the functor of the term is returned (For a list '.').

See: PL_get_arg/3

Declaration Syntax
C# Visual Basic Visual C++
public PlTerm this[
	int pos
] { get; }
Public ReadOnly Default Property Item ( _
	pos As Integer _
) As PlTerm
	Get
public:
property PlTerm default[int pos] {
	PlTerm get (int pos);
}
Parameters
pos (Int32)
To Get the nth PlTerm
Return Value
a PlTerm
Examples
CopyC#
[TestMethod]
public void PlTermIndexer2()
{
    PlTerm t = PlTerm.PlCompound("foo(bar, x(y))");
    Assert.AreEqual("foo", t[0].ToString());
    Assert.AreEqual("bar", t[1].ToString());
    Assert.AreEqual("x(y)", t[2].ToString());
}

[TestMethod]
public void PlTermIndexer_list1()
{
    PlTerm t = PlTerm.PlCompound("[a,b,c]");
    Assert.AreEqual(".", t[0].ToString());
    Assert.AreEqual("a", t[1].ToString());
    Assert.AreEqual("[b,c]", t[2].ToString());
}
Exceptions
Exception Condition
NotSupportedException Is thrown if PlTerm is not of Type PlCompound see IsCompound
ArgumentOutOfRangeException Is thrown if (pos < 0 || pos >= Arity)
InvalidOperationException Is thrown if PL_get_arg returns 0.

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