There are no real loops like that in Prolog. I am also not sure if it is wise to use assert
to dynamically change the fact database (it is usually better to represent your data in a structure). But if you really insist to use a "loop" for its side effects, you should be using forall
:
?- forall( between(-1,1,X), format('~d~n', [X]) ).
-1
0
1
true.