Re: negotiation by failure- list operations





Google groups seems to have corrupted my code sample in the previous
post, mixing it in with other code. The working code should be (as long
as Google doesn't mess this up too):

> The following code does work:
>
> member(X,[X|_]).
> member(X,[_|T]) :- member(X,T).
>
> delete1(X,List,List) :-
> \+ member(X,List),!.
> delete1(X,List,ListWithoutX) :-
> delete(X, List, ListWithoutX).
>
> % strange version of delete that only deletes
> % the first matching element...
> delete(E,[E|T],T).
> delete(E,[H|T],[H|DT]) :-
> delete(E,T,DT).
>

.