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,[HT],Result):-We 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(+,-).
everything_after_a([HeadTail],Result):-Again, there are no parameters. There is one input (also the recursion argument) and one output argument (also the result argument).
Head = a,
Result = Tail.
The first clause can be rewritten to:everything_after_a([aTail],Tail).Again, 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.