Suppose I have a predefined list such below, and i want to retrieve each member from the list non-deterministically:
new_list(List) :- assert(predefined(List)). list_item(X) :- predefined(List), member(X, List).
Suppose I now want to cycle through the list,i.e. when the last item of the list was retrieved via backtracking, i want to start obtaining the first item again. So, list_item(X), backtracks infinitely, and without generation of excess memory.
Can this be accomplished?