Circular Lists- back to content

	Example:
		?- circular([a,b,c,d],R).
		[a,b,c,d]
		[b,c,d,a]
		[c,d,a,b]
		[d,a,b,c]
		

circular(L,R):- circ(L,L,R). circ(_,[],_). circ([H|T],[_|Rest],R):- append(T,[H],R),write(R),nl,circ(R,Rest,R1). Take the list [a,b,c,d] and put the first element at the end. Do the same with the resulting list R (R=[b,c,d,a]) When do we know how to stop? We introduce another variable which we initiliaze by [a,b,c,d]. Each time we obtain a new list we take one element from it. We stop when this list is [].