File "sequence"

This is reduced re-implementation of the corresponding library from formerly Jekejeke Prolog. Unlike the latter, which makes use of a Java Pivot data structure, this implantation is based on change_arg/3. This module is inspired by SQL query options such as TOP. Providing such a module was recently pioneered by SWI-Prolog.

Currently the predicates limit/2, offset/2 and call_nth/2 are provided. The current implementation of limit/2 and offset/2 is based on call_nth/2. The predicates limit/2, offset/2 and call_nth/2 solely work tuple oriented and it is possible to cascade these predicates as the example below shows:

Example:
?- limit(5, offset(3, between(1, 10, X))).
X = 4 ;
X = 5 ;
X = 6 ;
X = 7 ;
X = 8

The following sequence predicates are provided:

limit(C, G):
The predicate succeeds whenever the goal G succeeds, but limits the number of solu-tions to C.
offset(C, G):
The predicate succeeds whenever the goal G succeeds, except the first C solutions are supressed.
call_nth(G, C):
The predicate succeeds whenever G succeeds and unifies C with the numbering of the successes.
distinct(G):
The predicate succeeds eagerly with first solutions of G.
firstof(T, Q):
The predicate succeeds eagerly with first solutions of T in Q.

Kommentare