From: Kevin Mayall
Subject: Using set-difference
Date: 
Message-ID: <Dy5C6s.EMD@watserv3.uwaterloo.ca>
I can't seem to understand why the second expression below does not
return ((A) (C)).  Can anyone provide some insight?   

> (set-difference '(a b c) '(d e b f))
(A C)
> (set-difference '((a) (b) (c)) '((d) (e) (b) (f)))
((A) (B) (C))

Cheers..........

	Kevin










-- 
--------------------------------Bermuda Massive
Kevin Mayall               ·······@uwaterloo.ca
         http://www.fes.uwaterloo.ca/u/kmayall/
     School of Planning, University of Waterloo

From: Kevin Mayall
Subject: Re: Using set-difference
Date: 
Message-ID: <Dy5CJD.Exo@watserv3.uwaterloo.ca>
In article <··········@watserv3.uwaterloo.ca>,
Kevin Mayall <·······@cousteau.uwaterloo.ca> wrote:
>I can't seem to understand why the second expression below does not
>return ((A) (C)).  Can anyone provide some insight?   
>
>> (set-difference '(a b c) '(d e b f))
>(A C)
>> (set-difference '((a) (b) (c)) '((d) (e) (b) (f)))
>((A) (B) (C))

Sorry - of course, it dawned on me five minutes after posting.
Set-difference uses #'eql as the default, when I should be testing
for #'equal.

Thanks anyway........

	Kev



-- 
--------------------------------Bermuda Massive
Kevin Mayall               ·······@uwaterloo.ca
         http://www.fes.uwaterloo.ca/u/kmayall/
     School of Planning, University of Waterloo
From: Robert W. Schaaf
Subject: Re: Using set-difference
Date: 
Message-ID: <32484F20.36A7@m5.sprynet.com>
> I can't seem to understand why the second expression below does not
> return ((A) (C)).  Can anyone provide some insight?   
> 
> > (set-difference '(a b c) '(d e b f))
> (A C)
> > (set-difference '((a) (b) (c)) '((d) (e) (b) (f)))
> ((A) (B) (C))

It's because of the default test, which I suspect is #'eql.

? (eql 'b 'b)
t
? (eql '(b) '(b))
nil
? (equal '(b) '(b))
t

To get the result you want, be explicit in your match function.

? (set-difference '((a) (b) (c)) '((d) (e) (b) (f)) :test #'equal)
((c) (a))

cheers,

Bob Schaaf