for( I, A, B),
for( I, A, B, step(Step))
Makes a loop in which the value of I is moving between A and B with step Step. If Step is missing then the default step is one.
I starts from A and it last value is =< B if step is positive and is >= B if step is negative.
?- for( I, 10, 1, step(-1)), write(I), write(" "), fail.
This example will write:
10 9 8 7 6 5 4 3 2 1 No