Now we turn to the idea that we can return a result. This requires an extra argument to be carried around ---termed the result argument. We will now outline two further schemata that can be seen as developments of the two above. The first is intended to work through a list until an element satisfies some condition whereupon we stop and return some result. The schema is:
return_after_event( Info [HWe will illustrate this with a predicate everything_after_a/2 that takes a list and returns that part of the list after any occurrence of the element a. We assume that the mode is mode everything_after_a(+ -).T] Result):-
property( Info H)
result( Info H T Result).
return_after_event( Info [Head
Tail] Ans):-
return_after_event( Info Tail Ans).
everything_after_a([HeadAgain there are no parameters. There is one input (also the recursion argument) and one output argument (also the result argument).Tail] Result):-
Head = a
Result = Tail.
everything_after_a([Head
Tail] Ans):-
everything_after_a(Tail Ans).
The first clause can be rewritten to:everything_after_a([aAgain there is the same problem with this program as with the test for existence schema. The goal everything_after_a([d a s a f] X) will succeed with X=[s a f]. On redoing the goal can be resatisfied with X=[f]. This suggest that we have to be very careful about the meaning of this predicate.Tail] Tail).