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
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
> 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