Predicates that generate integers
These predicates can be used to reason about integers in a reduced domain that follow some property.
library(clpz) provides another way of reasoning about integers that may also be interesting.
between(+Lower, +Upper, -X).
Given Lower and Upper are both integer numbers, true iff X is an integer so that Lower =< X =< Upper. Can be used both to check if X is between Lower and Upper or to generate an integer between Lower and Upper.
?- between(10, 20, 15). true. ?- between(10, 20, 25). false. ?- between(3, 5, X). X = 3 ; X = 4 ; X = 5.
True iff N is an integer.
True iff N is a natural number.
True iff List is the list of integers [1, ..., Upper]. Example:
?- numlist(X, Y). X = 1, Y = , ; X = 2, Y = [1,2] ; X = 3, Y = [1,2,3] ; ... .
numlist(?Lower, ?Upper, ?List).
True iff List is a list of the form [Lower, ..., Upper]. Example:
?- numlist(5, 10, X). X = [5,6,7,8,9,10].
Succeeds N times. This predicate is only included for compatibility and should not be used because it lacks a declarative interpretation.