domains
list=integer*
predicates
shift(list,list)
del(list,list,integer)
add(list,integer,list)
clauses
shift(L1,L2):-
del(L1,L3,X),
add(L3,X,L2).
del([X],[],X).
del([Head|Tail],[Head|L],X):-
del(Tail,L,X).
add(L3,X,[X|L3]).
OUT PUT
=======
Goal: shift([1,2,3,4,5],List)
List=[5,1,2,3,4]
1 Solution
-------------------------------------
Goal: shift([1,2,3,4,5,6,7,8,9],List)
List=[9,1,2,3,4,5,6,7,8]
1 Solution