Hello all, I need an argument correct(L, X, NL) where L is a list of names, X is a name that exists twice in L and NL is the new list with the name X once.
I wrote this:
correct([], _, _).
correct([H|T], X, NL):-
NL= [H|NL1],
not(member(X, NL)),
correct(T, X, NL1).
correct([H|T], X, NL):-
member(X, [H|NL]),
correct(T, X, NL).
but it doesnt work, any ideas?
thanks in advance.
I wrote this:
correct([], _, _).
correct([H|T], X, NL):-
NL= [H|NL1],
not(member(X, NL)),
correct(T, X, NL1).
correct([H|T], X, NL):-
member(X, [H|NL]),
correct(T, X, NL).
but it doesnt work, any ideas?
thanks in advance.