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 > remove items ap...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 4620 of 4700
Post > Topic >>

remove items appearing in both lists

by "xahlee@[EMAIL PROTECTED] " <xahlee@[EMAIL PROTECTED] > Jul 20, 2008 at 07:14 AM

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

order doesn't matter.

i think i can go thru each element and build OlistNew, and removing
Clist to build a ClistNew. But the checking existance and building
item by item would be difficult or very inefficient i think but am not
sure about lisp here.

should i turn them both into hash table first for easy checking
existance?

Thanks.

  Xah
=E2=88=91 http://xahlee.org/

=E2=98=84
 




 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 Wed Aug 27 20:54:18 CDT 2008.