constructs a for loop
INCLUDE 'prolib.h' for(1,5,X), write(X),nl, X = 5.
for(Start,End,Count)(i)(i)(o)
integer(Start) (i) Value to start count from
integer(End) (i) Value which is the last count
integer(Count) (o) will be bound to any integer value between Start and End
inclusively
This is a standard prolog predicate. Its has End-Start+1 solutions with Count representing
all integers in-between Start and End. You can use the '
=
'
predicate as a next.
Its definition is:
PREDICATE for(integer,integer,integer). for(X,Y,X):- bound(X),bound(Y). for(X,Y,Z):- X<Y, X1 is X+1, for(X1,Y,Z).
for(1,5,X), write(X),nl, X = 5, % next(X) write(done),nl.
No runtime errors.
prolog-process, client-server, object