Appendix A.5

Built-in predicates


 

 

InRange(Out N,A,B)

Enumerate all integers N such that A<=N<=B

Description:

InRange may be used as an enumerator engine to generate all integers in the range [A,B]. Actually enumerated values are: A, A+1, ..., B-1, B.

Note if A>B InRange fails and no value is enumerated.

Example:

/**

Graph(Out 1);

Node(Out N,1) For N:InRange(N,1,10);

**/

"Declare a graph, then enumerates its nodes 1 .. 10 by calling the InRange predicate."

 

InRangeStep(Out N,A,B,S)

Enumerate all integers N such that A<=N<=B and S|(N-A)

Description:

InRangeStep may be used as an enumerator engine to generate all integers N in the range [A,B] such that N-A is a multiple of S. Actually enumerated values are: A, A+S, A+2*S, ... A+k*S such that k=floor((B-A)/S).

Note if A>B InRangeStep fails and no value is enumerated.

Example:

/**

Tree(Out 1);

Node(Out N,1)

For N:InRangeStep(X,1,25,5);

**/

"Declare a tree, then declare nodes 1, 6, 11, 16, 21."