This library implements the when/2 constraint, delaying a goal until its arguments are sufficiently instantiated. For example, the following delayes the execution of =:=/2 until the expression is instantiated.
... when(ground(Expr), 0 =:= Expr),
- when(+Condition, :Goal)
- Execute Goal when Condition is satisfied. I.e., Goal is executed
as by call/1 if Condition is true when when/2 is called.
Otherwise Goal is delayed until Condition becomes true.
Condition is one of the following:
For example (note the order
?- when(nonvar(X), writeln(a)), writeln(b), X = x. b a X = x