The definition of drotate can be simplified:
dapp(AB,BC,AC). drotate([H|T]-T1,RS) :- % dapp(T-T1,[H|L]-L,RS). %% use the definition of dapp: T=R, T1=[H|L], L=S.
IOW, just
drotate([H|R]-[H|L],RL).
Now any list of differences is usually written out as a pair, AB . Thus, a call to drotate can be drotate([1,2,3|Z]-Z,RL) with the intention of seeing the output in RL variables. But comparing this call with the last definition, we get Z=[1|L] , that is, the logarithm of Z, presumably not created before the call, gets an instance of it, actually adding 1 to the end of the open list [1,2,3|Z]-Z turning it into [1,2,3,1|L]-L . R simply points to the second elt of the recently enlarged list, matching [H|R] with the list.
?- drotate([1,2,3|Z]-Z,RL). Z = [1|_G345] R = [2, 3, 1|_G345] L = _G345 Yes
But it can also be called with true circular data, AA=[1,2,3|Z]-Z, drotate(AZ,RL) :
?- AA=[1,2,3|Z]-Z, drotate(AZ,RL). A = [1, 2, 3, 1, 2, 3, 1, 2, 3|...] Z = [1, 2, 3, 1, 2, 3, 1, 2, 3|...] R = [2, 3, 1, 2, 3, 1, 2, 3, 1|...] L = [2, 3, 1, 2, 3, 1, 2, 3, 1|...] Yes