Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Scheme > Re: remove item...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 10 Topic 4620 of 4788
Post > Topic >>

Re: remove items appearing in both lists

by Kaz Kylheku <kkylheku@[EMAIL PROTECTED] > Jul 22, 2008 at 10:36 PM

On 2008-07-20, xahlee@[EMAIL PROTECTED]
 <xahlee@[EMAIL PROTECTED]
> wrote:
> Given 2 lists Olist and Clist. I want to remove items that appears in
> both list. How best to do this?
>
> Say,
>
> (setq Olist (list "a" "b" "c" "d" "e"))
> (setq Clist (list "ee" "a" "d" "c" "bb"))
>
> i want the result to be like
>
> (setq Olist (list "b" "e"))
> (setq Clist (list "ee" "bb"))

Since you're assigning to variables, wouldn't this be off-topic in
comp.lang.functional? :)

> order doesn't matter.

 ;; items common to both sets

 (intersection '("a" "b" "c") '("b" "c" "d") :test #'equal)

 -> ("b" "c")

 ;; items in the left set which are not in the right set

 (set-difference '("a" "b" "c") '("b" "c" "d") :test #'equal)

 -> ("a")

You want to remove (via set-difference) from each original list the
intersection of those two lists:
 




 10 Posts in Topic:
remove items appearing in both lists
"xahlee@[EMAIL PROTE  2008-07-20 07:14:51 
Re: remove items appearing in both lists
"xahlee@[EMAIL PROTE  2008-07-20 07:16:44 
Re: remove items appearing in both lists
Jon Harrop <jon@[EMAIL  2008-07-22 12:29:16 
Re: remove items appearing in both lists
"xahlee@[EMAIL PROTE  2008-07-22 14:33:42 
Re: remove items appearing in both lists
Kaz Kylheku <kkylheku@  2008-07-22 22:36:52 
Re: remove items appearing in both lists
David Kastrup <dak@[EM  2008-07-23 08:49:03 
Re: remove items appearing in both lists
"John Thingstad"  2008-07-23 12:04:53 
Re: remove items appearing in both lists
Dr Jon D Harrop <jon@[  2008-07-23 03:15:10 
Re: remove items appearing in both lists
David Kastrup <dak@[EM  2008-07-23 12:17:08 
Re: remove items appearing in both lists
Dr Jon D Harrop <jon@[  2008-07-23 03:18:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 22:29:30 CDT 2008.