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++ | F# |
public PlTerm this[ int position ] { get; }
Public ReadOnly Default Property Item ( position As Integer ) As PlTerm Get
public: property PlTerm default[int position] { PlTerm get (int position); }
member Item : PlTerm with get
Parameters
- position (Int32)
- To Get the nth PlTerm
Return Value
PlTerm
a PlTerm
a PlTerm
Examples
Copy | |
---|---|
[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.dll) Version: 1.1.60601.0 (1.1.60601.0)