The class PlTail is both for analysing and constructing lists. It is called PlTail as enumeration-steps make the term-reference follow theātail' of the list.
"gnat",
a list of the form [gnat|B] is created and the PlTail
object now points to the new variable B.
This function returns TRUE if the unification succeeded
and
FALSE otherwise. No exceptions are generated.
The example below translates the main() argument vector to Prolog and calls the prolog predicate entry/1 with it.
int
main(int argc, char **argv)
{ PlEngine e(argv[0]);
PlTermv av(1);
PlTail l(av[0]);
for(int i=0; i<argc; i++)
l.append(argv[i]);
l.close();
PlQuery q("entry", av);
return q.next_solution() ? 0 : 1;
}
[] and returns the
result of the unification.TRUE
on success and FALSE if
PlTail represents the empty list.
If PlTail is neither a list nor the
empty list, a type_error is thrown. The example below
prints the elements of a list.
PREDICATE(write_list, 1)
{ PlTail tail(A1);
PlTerm e;
while(tail.next(e))
cout << (char *)e << endl;
return TRUE;
}