Go to the first, previous, next, last section, table of contents.


All solutions predicates

Author(s): First version by Richard A. O'Keefe and David H.D. Warren. Changes by Mats Carlsson, Daniel Cabeza, and Manuel Hermenegildo.

Version: 1.5#118 (2000/4/19, 18:13:43 CEST)

Version of last change: 1.5#115 (2000/4/12, 12:17:22 CEST)

This module implements the standard solution aggregation predicates.

When there are many solutions to a problem, and when all those solutions are required to be collected together, this can be achieved by repeatedly backtracking and gradually building up a list of the solutions. The following built-in predicates are provided to automate this process.

Usage and interface (aggregates)

Documentation on exports (aggregates)

PREDICATE: setof/3:

Meta-predicate with arguments: setof(?,goal,?).

Usage: setof(@(Template),+Generator,?(Set)) * ISO *

PREDICATE: bagof/3:

Meta-predicate with arguments: bagof(?,goal,?).

Usage: bagof(@(Template),+Generator,?(Bag)) * ISO *

PREDICATE: findall/3:

Meta-predicate with arguments: findall(?,goal,?).

Usage: findall(?(Template),+Generator,?(List)) * ISO *

PREDICATE: findall/4:

Meta-predicate with arguments: findall(?,goal,?,?).

Usage: findall(?(Template),+Generator,?(List),?(Tail)) * ISO *

PREDICATE: findnsols/4:

findnsols(N,Template,Generator,List)

As findall/3, but generating at most N solutions of Generator. Thus, the length of List will not be greater than N. If N=<0, returns directly an empty list. This predicate is especially useful if Generator may have an infinite number of solutions.

Meta-predicate with arguments: findnsols(?,?,goal,?).

PREDICATE: findnsols/5:

findnsols(N,Template,Generator,List,Tail)

As findnsols/4, but returning in Tail the tail of List.

Meta-predicate with arguments: findnsols(?,?,goal,?,?).

PREDICATE: ^/2:

Usage: X ^ P


Go to the first, previous, next, last section, table of contents.