fix nth/4 going backwards (obs from Daniel Diaz).

This commit is contained in:
Vitor Santos Costa 2009-10-23 23:19:55 +01:00
parent 0ea348c26d
commit 981d060ffb

View File

@ -135,7 +135,7 @@ find_nth(N, [_|Tail], Elem) :-
generate_nth(I, I, [Head|_], Head). generate_nth(I, I, [Head|_], Head).
generate_nth(I, IN, [_|List], El) :- generate_nth(I, IN, [E|List], El) :-
I1 is I+1, I1 is I+1,
generate_nth(I1, IN, List, El). generate_nth(I1, IN, List, El).
@ -184,7 +184,7 @@ find_nth(N, [Head|Tail], Elem, [Head|Rest]) :-
generate_nth(I, I, [Head|Tail], Head, Tail). generate_nth(I, I, [Head|Tail], Head, Tail).
generate_nth(I, IN, [_|List], El, Tail) :- generate_nth(I, IN, [E|List], El, [E|Tail]) :-
I1 is I+1, I1 is I+1,
generate_nth(I1, IN, List, El, Tail). generate_nth(I1, IN, List, El, Tail).