Subject: Re: troubles with SWI -Prolog

From: [email-masked] (Uwe Lesta)
Date: Wed, 13 Sep 2000 22:27:14 +0200

> Ed Kovach schrieb:
> 
> Hi,
> 
> I'm having some problems getting some list operations to work.  The code is below
> 
> member1(X, [X | Tail] ).
> 
> member1(X, [Head | Tail] ) :- member1(X, Tail).
> 
> conc([ ], L, L).
> 
> conc( [X | L1], L2, [ X | L3] ) :- conc(L1, L2, L3).
> 
> add(X, L, [X|L]).
> 
> del( X, [X | Tail], Tail).
> 
> del (X, [ Y| Tail ], [ Y | Tail1] ) :- del(X, Tail, Tail1).
> 
> Member, conc and add work fine.  The del does not.  When I load the program using consul, I get an error that there is an operator excepted in line 12 (the last line.)  I don't see anything wrong.
> I should note that I did have similar problems with conc.  It cleared up after I corrected an error in member1 (I forgot the ] to close the fist list in the first clause of member1.

the code must be:

member1(X, [X | _Tail] ).
member1(X, [_Head | Tail] ) :- member1(X, Tail).

conc([ ], L, L).
conc( [X | L1], L2, [ X | L3] ) :- conc(L1, L2, L3).

add(X, L, [X|L]).

del( X, [X | Tail], Tail).
del(X, [ Y| Tail ], [ Y | Tail1] ) :- del(X, Tail, Tail1).

It is not allowd to have a space between the predicate_name and the open bracket.

-- 

Regards

Uwe
[email-masked]