I want to write a program which deletes every Nth element from a list without the last one. My program is already working fine and gives me the correct result, but when I ask for another result, prolog comes with the error ">/2: Arguments are not sufficiently instantiated". Here is the code I have so far:
delete_elements([],0,[]).
delete_elements([],_,[_|_]).
delete_elements(L,N,R) :-
length(L,LL),
LL > N,
nth1(N,L,_,RZ),
NZ is N + 1,
delete_elements(RZ,NZ,RR),
R = RR.
delete_elements(L,N,R) :-
length(L,LL),
LL =< N,
delete_elements([],_,R),
L = R.
I think that there is something wrong with the cancellation condition of the recursion. How to fix this?
Thanks in advance!