Finding One Solution of a Call

The easiest way to call a predicate if you are only interested in the first solution is to call the function SP_query(). It will create a goal from the predicate definition and the arguments, call it, and commit to the first solution found, if any.

Returns SP_SUCCESS if the goal succeeded, SP_FAILURE if it failed, and SP_ERROR if an error condition occurred. Only when the return value is SP_SUCCESS are the values in the query arguments valid, and will remain so until backtracking into any enclosing query:

     int SP_query(SP_pred_ref predicate, SP_term_ref arg1, ...)
     

If you are only interested in the side-effects of a predicate you can call SP_query_cut_fail(). It will try to prove the predicate, cut away the rest of the solutions, and finally fail. This will reclaim the storage used after the call, and throw away any solution found. The return values are the same as for SP_query().

     int SP_query_cut_fail(SP_pred_ref predicate, SP_term_ref arg1, ...)