decision
¶(decision condition traversal-A traversal-B)
or
(if condition traversal-A traversal-B)
Do either traversal A or traversal B, depending on whether a condition holds.
The condition can be any predicate — either a built-in predicate form, or an arbitrary traversal, including a lambda. See Predicates for details.
"If we’re at the root of the tree, then go forward, otherwise go down."
(symex-eval (symex-traversal (if (at root) (move forward) (move down))))
"If we are somewhere before a previously stored position in the buffer, then go forward, otherwise don’t move."
(symex-eval (symex-traversal (if (lambda (_computation _result) (< (point) previously-stored-position)) (move forward) symex--move-zero)))
We’ll ignore the arguments of the lambda here, for now, and will soon see what they’re for. symex--move-zero
is just a convenient traversal for cases where you need to indicate a traversal but would like to not move at all. It is defined as (symex-make-move 0 0)
.