Hi,
I have predicates, that are basically procedural code, such as when asserting new facts, and all the checks that need to be done before hand, where i don’t want to see choice points. To ensure that I now use once/1 extensively, but I am wondering if there is a better approach,
Any thoughts are much appreciated.
For example,
a1 (Return) :-
once(p1), % precondition p1
once(p2), % precondition p2
once(p3),
…
once(pn),
Return = ok.
a1(Error) :-
not(p1),
Error = “p1 failed”.
a1(Error) :-
not(p2),
Error = “p2 failed”.
is there a better way to avoid all the many once/1