precaution
¶(precaution traversal [(beforehand condition)|(afterwards condition)])
or
(carefully traversal [(beforehand condition)|(afterwards condition)])
Execute a traversal, but ensure that certain conditions hold either before or after executing the traversal (or both). If a condition does not hold, then abort the traversal, considering it to have failed.
Each of the conditions can be any predicate — either a built-in predicate form, or an arbitrary traversal, including a lambda. See Predicates for details.
Note that, as the predicates could be lambdas, you could also perform effects resembling effect
(say, setting an ELisp variable) using precaution
, either before or after the traversal. If you’d like to do this, just remember that the effect function you use, as a predicate, must return a truthy value. And further, as a traversal, it must accept the two standard arguments to traversals (See Lambdas).
"Go down but don’t descend to the root node."
(symex-eval (symex-traversal (carefully (move down) (afterwards (not (at root))))))
"Go backward as long as we aren’t at the first node at this level."
(symex-eval (symex-traversal (carefully (move backward) (beforehand (not (at first))))))
Note that this executes a *single* traversal while taking precautions. It is not repeated unless wrapped in a circuit or employed as a detour.