5.6 Backtracking
TBoS p.129-136
Backtracking is invoked in a Shen function f by using <-
in place of ->. The effect is that the expression after the <- is
returned only if it does not evaluate to the failure object (fail).
If (fail) is returned; then the next rule in f is applied.
(0-) (define foo
X <- (if (integer? X) 0 (fail))
X -> X)
(fn foo)
(1-) (foo 5)
0
(2-) (foo a)
a |
|