>>109780844
Goal-direction with backtracking works differently than if-else. The guards are position independent and can appear anywhere in the alternate. I don't have to check them first, and if a guard fails, backtracking will undo any changes made to the environment in the failed alternate before it tries another alternate.
This is also a working fizzbuzz:
fizzbuzz(*n)::
"Fizz" eq(mod(*n,"3"), "0") !eq(mod(*n,"5"), "0")
| "Buzz" !eq(mod(*n,"3"), "0") eq(mod(*n,"5"), "0")
| "Fizzbuzz" eq(mod(*n,"3"), "0") eq(mod(*n,"5"), "0")
| *n !eq(mod(*n,"3"), "0") !eq(mod(*n,"5"), "0");
So is this:
fizzbuzz(*n)::
eq(mod(*n,"3"), "0") "Fizz" !eq(mod(*n,"5"), "0")
| !eq(mod(*n,"3"), "0") "Buzz" eq(mod(*n,"5"), "0")
| eq(mod(*n,"3"), "0") "Fizzbuzz" eq(mod(*n,"5"), "0")
| !eq(mod(*n,"3"), "0") *n !eq(mod(*n,"5"), "0");
Goal-direction is sort of like squashing the functionality of if-else and try-catch together, without needing booleans or having to lead with the guard.