I have a recursive predicate:
something(A, Object, Value, Complete) :-
member(Value, Complete), Object = Value.
something(A, Object, _, Complete) :-
objects(Object),
\+ member(Object, Complete),
!,
<Predicates to get return values>,
something(A, NewObject, Object, [Object|Complete]).
The function of this predicate is to iterate through all facts of Object, run some further logic processing on it and then output the results for each Object fact that is apart of objects.
The issue I'm having is that all the return values I get (upon pressing ;) are all of the first iteration, so the first value that this recursive function returned for Object.
EG: The output I see:
Object: obj1
Object: obj1
Where it should really be
Object: obj1
Object: obj2
(Along with the other variables, however I've left them out to keep the post cleaner).
Upon using the visual debugger in SWI Prolog implementation, I can see that once the inner recursive calls return, the values of the inner recursions are lost and that's why I'm seeing obj1
again for the second return value.
I'm not too sure how I can save these inner values, I've looked at lots of examples of recursive functions but I can't seem to apply the concepts to this specific instance.
findall(Object, <Predicates to get return values>, Complete)
– CapelliC