From ok@atlas.otago.ac.nz  Mon Dec 18 23:46:13 2000
Received: from atlas.otago.ac.nz (atlas.otago.ac.nz [139.80.32.250])
	by swi.psy.uva.nl (8.9.3/8.9.3) with ESMTP id XAA26992
	for <prolog@swi.psy.uva.nl>; Mon, 18 Dec 2000 23:46:10 +0100 (MET)
Received: (from ok@localhost)
	by atlas.otago.ac.nz (8.9.3/8.9.3) id LAA26968;
	Tue, 19 Dec 2000 11:46:19 +1300 (NZDT)
Date: Tue, 19 Dec 2000 11:46:19 +1300 (NZDT)
From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
Message-Id: <200012182246.LAA26968@atlas.otago.ac.nz>
To: i960242@dei.isep.ipp.pt, prolog@swi.psy.uva.nl
Subject: Re:  [SWIPL] Prolog

Nuno Baptista <i960242@dei.isep.ipp.pt> wrote:

	I'm trying to find [an] algorithm to find if there are equal
	elements in [two] given lists.

This is rather vague.  It sounds as though you want to know whether
two lists have a non-empty intersection.

	Here is the code :
	
	lista([], [], L):- !.
	lista([H1|T1], L, R):-
		member(H1, L),
		lista([H1|T1], L, [H1|R]).
	lista([H1|T1], [H2|T2], L):-
		lista(T1, T2, L).
	
This is _almost_ "compute the intersection", but the third clause
is strange.  Could it be that you want

    %   intersection(+As:list(T), +Bs:list(T), ?ABs:list(T))
    %   is true when ABs is a subsequence of As containing all
    %   and only the elements of As which are also elements of Bs.

    intersection([], _, []).
    intersection([A|As], Bs, ABs) :-
	\+ member(A, Bs),
	!,
	intersection(As, Bs, ABs).
    intersection([A|As], Bs, [A|ABs]) :-
	intersection(As, Bs, ABs).

