Drop links or images here to add them to the editor.

Write a predicate rotate/2 that is true if the difference list in the second argument is the difference list in the first argument rotated. You may assume that the tail of the difference list in the first argument is not bound when called.

For example 1,2,3,4 becomes 2,3,4,1

?- rotate([1,2,3,4|X]-X, B-[]).
X = ...,
B = [2, 3, 4, 1].