Re: negotiation by failure- list operations
- From: "ne0" <neoeon@xxxxxxx>
- Date: 14 Jun 2005 05:03:42 -0700
all i need is a modified delete1 predicate that throws back a YES if x
isnt in the List. - the point is the yes - not deleting all matching
elements in the list.
its like a if then construction
delete1(x,[L1],Y).
if x isnt in the list - then halt and give back a YES, if x is in the
list- procede with delete
Has nobody an idea ?
Greetings
Brian Hulley schrieb:
> > > % 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).
>
> (The above delete/3 needs a cut as well ie delete(E,[E|T],T) :- !. )
>
> Normal efficient delete that deletes all matching elements and
> therefore always succeeds regardless of E:
>
> delete(_,[],[]).
> delete(E,[E|T],DT) :- !, delete(E,T,DT).
> delete(E,[H|T],[H|DT]) :- delete(E,T,DT).
.
- Follow-Ups:
- Re: negotiation by failure- list operations
- From: Brian Hulley
- Re: negotiation by failure- list operations
- References:
- negotiation by failure- list operations
- From: ne0
- Re: negotiation by failure- list operations
- From: Brian Hulley
- Re: negotiation by failure- list operations
- From: ne0
- Re: negotiation by failure- list operations
- From: Brian Hulley
- Re: negotiation by failure- list operations
- From: matthiasse
- Re: negotiation by failure- list operations
- From: Brian Hulley
- Re: negotiation by failure- list operations
- From: Brian Hulley
- Re: negotiation by failure- list operations
- From: Brian Hulley
- negotiation by failure- list operations
- Prev by Date: Re: negotiation by failure- list operations
- Next by Date: Re: negotiation by failure- list operations
- Previous by thread: Re: negotiation by failure- list operations
- Next by thread: Re: negotiation by failure- list operations
- Index(es):
Relevant Pages
|
|