:- use_module(library(aggregate)).(can be autoloaded)
The implementation executes forall/2 if Goal does not contain any variables that are not shared with Generator.
Here is an example:
?- foreach(between(1,4,X), dif(X,Y)), Y = 5. Y = 5. ?- foreach(between(1,4,X), dif(X,Y)), Y = 3. false.
Tag confusing pages with doc-needs-help|Tags are associated to your profile if you are logged in