diff --git a/library/lists.yap b/library/lists.yap index c00d4495c..3bb4198be 100644 --- a/library/lists.yap +++ b/library/lists.yap @@ -135,7 +135,7 @@ find_nth(N, [_|Tail], Elem) :- generate_nth(I, I, [Head|_], Head). -generate_nth(I, IN, [_|List], El) :- +generate_nth(I, IN, [E|List], El) :- I1 is I+1, 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, IN, [_|List], El, Tail) :- +generate_nth(I, IN, [E|List], El, [E|Tail]) :- I1 is I+1, generate_nth(I1, IN, List, El, Tail).