% app(L1,L2,L3) <=> list concatenation app([] ,L,L ). app([E|R],L,[E|RL]) :- app(R,L,RL). % add an elementat the end of a list: add_list(L,E,LandE) :- app(L,[E],LandE). % compute the last element of a list: last(L,E) :- app(_,[E],L). % is an element member of a list elem(E,L) :- app(_,[E|_],L). % removes an occurrence of an element from a list remove(E,L,LwithoutE) :- app(Xs,[E|Ys],L), app(Xs,Ys,LwithoutE). % sublist(T,L) <=> T is a sublist of L sub(T,L) :- app(_,Zs,L), app(T,_,Zs).