From: webmasterATflymagnetic.com
Subject: How do you remove an item from a list?
Date: 
Message-ID: <1f16bba0-e270-4b5b-b886-94331b13d3cf@z38g2000hsc.googlegroups.com>
I know you can use:

   (remove 2 '(1 2 3)) => (1 3)

But why does this not work?

   (remove "a" '("a" "b" "c"))

It simply returns the second list: ("a" "b" "c")

Any help greatly appreciated.

From: Jason
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <df5b0176-e40a-4d01-82d9-bde9b06ae22d@u10g2000prn.googlegroups.com>
On Mar 17, 2:32 pm, "webmasterATflymagnetic.com"
<·········@flymagnetic.com> wrote:
> I know you can use:
>
>    (remove 2 '(1 2 3)) => (1 3)
>
> But why does this not work?
>
>    (remove "a" '("a" "b" "c"))
>
> It simply returns the second list: ("a" "b" "c")
>
> Any help greatly appreciated.

; SLIME 2006-04-20
CL-USER> (eq "a" "a")
NIL
CL-USER> (equal "a" "a")
T
CL-USER> (eq 2 2)
T
CL-USER> (equal 2 2)
T
CL-USER>
From: Ken Tilton
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <47df1840$0$25050$607ed4bc@cv.net>
Jason wrote:
> On Mar 17, 2:32 pm, "webmasterATflymagnetic.com"
> <·········@flymagnetic.com> wrote:
> 
>>I know you can use:
>>
>>   (remove 2 '(1 2 3)) => (1 3)
>>
>>But why does this not work?
>>
>>   (remove "a" '("a" "b" "c"))
>>
>>It simply returns the second list: ("a" "b" "c")
>>
>>Any help greatly appreciated.
> 
> 
> ; SLIME 2006-04-20
> CL-USER> (eq "a" "a")
> NIL
> CL-USER> (equal "a" "a")
> T
> CL-USER> (eq 2 2)
> T
> CL-USER> (equal 2 2)
> T
> CL-USER>

Major problem with the above: the default test for remove is EQL, so the 
EQ examples are misleading.

kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius
From: Jason
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <bb479254-e261-4949-b4f8-ecaaf5155da2@s19g2000prg.googlegroups.com>
On Mar 17, 6:17 pm, Ken Tilton <···········@optonline.net> wrote:
> Jason wrote:
> > On Mar 17, 2:32 pm, "webmasterATflymagnetic.com"
> > <·········@flymagnetic.com> wrote:
>
> >>I know you can use:
>
> >>   (remove 2 '(1 2 3)) => (1 3)
>
> >>But why does this not work?
>
> >>   (remove "a" '("a" "b" "c"))
>
> >>It simply returns the second list: ("a" "b" "c")
>
> >>Any help greatly appreciated.
>
> > ; SLIME 2006-04-20
> > CL-USER> (eq "a" "a")
> > NIL
> > CL-USER> (equal "a" "a")
> > T
> > CL-USER> (eq 2 2)
> > T
> > CL-USER> (equal 2 2)
> > T
> > CL-USER>
>
> Major problem with the above: the default test for remove is EQL, so the
> EQ examples are misleading.
>
> kenny
>
> --http://smuglispweeny.blogspot.com/http://www.theoryyalgebra.com/
>
> "In the morning, hear the Way;
>   in the evening, die content!"
>                      -- Confucius

Doh!
From: justinhj
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <88b455d7-ff98-4a19-a430-1ac04386e4e5@s37g2000prg.googlegroups.com>
On Mar 17, 2:32 pm, "webmasterATflymagnetic.com"
<·········@flymagnetic.com> wrote:
> I know you can use:
>
>    (remove 2 '(1 2 3)) => (1 3)
>
> But why does this not work?
>
>    (remove "a" '("a" "b" "c"))
>
> It simply returns the second list: ("a" "b" "c")
>
> Any help greatly appreciated.

The default test for equality in remove is eql and "a" does not eql
"a"

You need something like...

(remove "a" '("a" "b" "c") :test #'string=)


Justin
From: Kent M Pitman
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <uskyposa9.fsf@nhplace.com>
justinhj <········@gmail.com> writes:

> On Mar 17, 2:32�pm, "webmasterATflymagnetic.com"
> <·········@flymagnetic.com> wrote:
> > I know you can use:
> >
> > � �(remove 2 '(1 2 3)) => (1 3)
> >
> > But why does this not work?
> >
> > � �(remove "a" '("a" "b" "c"))
> >
> > It simply returns the second list: ("a" "b" "c")
> >
> > Any help greatly appreciated.
> 
> The default test for equality in remove is eql and "a" does not eql
> "a"

Well, more specifically, one particular "a" is not necessarily EQL to
another "a".

(let ((a "a") (b "b") (c "c"))
  (let ((abc (list a b c)))
    ;; show the list before something is removed
    (print abc)
    ;; return the list with something removed
    (remove a abc)))

("a" "b" "c") 
("b" "c")

In this case, it's not just any old "a", it's the very same one.
And EQL works fine here.
From: Matthias Benkard
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <52d8f814-07d9-416b-abe5-84df14584096@s12g2000prg.googlegroups.com>
Hi,

> But why does this not work?
>
>    (remove "a" '("a" "b" "c"))
>

That is because two distinct instances of "a" are not the same under
EQL.  As per CLHS 17.2.1, EQL is the default for two-argument
comparison tests.  If you want to compare strings character by
character, you have to specify #'EQUAL or #'STRING= as the test:

(remove "a" '("a" "b" "c") :test #'equal) => ("b" "c")

Hope this helps,
~ Matthias
From: webmasterATflymagnetic.com
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <66debc46-af76-48f6-9209-33545e2395f4@k13g2000hse.googlegroups.com>
On 17 Mar, 21:38, Matthias Benkard <··········@gmail.com> wrote:
> Hi,
>
> > But why does this not work?
>
> >    (remove "a" '("a" "b" "c"))
>
> That is because two distinct instances of "a" are not the same under
> EQL.  As per CLHS 17.2.1, EQL is the default for two-argument
> comparison tests.  If you want to compare strings character by
> character, you have to specify #'EQUAL or #'STRING= as the test:
>
> (remove "a" '("a" "b" "c") :test #'equal) => ("b" "c")
>
> Hope this helps,
> ~ Matthias

Brill! I didn't realise (I do know the difference between eql, equal,
etc). It's only by actually writing code that I'm starting to
internalise this!

Many thanks to all of you. And such quick responses too!

Cheers.
From: Ken Tilton
Subject: Re: How do you remove an item from a list?
Date: 
Message-ID: <47df1b50$0$5626$607ed4bc@cv.net>
webmasterATflymagnetic.com wrote:
> On 17 Mar, 21:38, Matthias Benkard <··········@gmail.com> wrote:
> 
>>Hi,
>>
>>
>>>But why does this not work?
>>
>>>   (remove "a" '("a" "b" "c"))
>>
>>That is because two distinct instances of "a" are not the same under
>>EQL.  As per CLHS 17.2.1, EQL is the default for two-argument
>>comparison tests.  If you want to compare strings character by
>>character, you have to specify #'EQUAL or #'STRING= as the test:
>>
>>(remove "a" '("a" "b" "c") :test #'equal) => ("b" "c")
>>
>>Hope this helps,
>>~ Matthias
> 
> 
> Brill! I didn't realise (I do know the difference between eql, equal,
> etc). 

Use EQ to distinguish any two lisp objects other than numbers and 
characters purely in re object identity. for chars and nums use EQL (or 
= for numbers).

When you want to see if two distinct sequences hapen to have the same 
content, use EQUAL.

hth,kenny

-- 
http://smuglispweeny.blogspot.com/
http://www.theoryyalgebra.com/

"In the morning, hear the Way;
  in the evening, die content!"
                     -- Confucius