Re: List element replacement.
- To: mathgroup at smc.vnet.net
- Subject: [mg52016] Re: List element replacement.
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 7 Nov 2004 01:03:39 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 11/6/04 at 2:07 AM, rgwv at rgwv.com (Robert G. Wilson v) wrote: >HELP, I tried this once before but what I received back I could not >make it work. Therefore I am following the adage that if at first >you do not succeed then wait awhile, rethink, restate and resubmit. >I have three lists of objects, sorted but not unioned, that is >there are elements which will be repeated. Let us label them >'initial' list, 'compare' list, and 'replace' list. If all of the >elements in the 'compare' list, including repeats, are in the >'initial' list, then remove those elements and put in the elements >from the 'replace' list. It would be useful when you post something like this to give specific small examples showing what you are starting with and the desired result. Possibly something like initial = {1, 1, 2, 3, 33, 4, 4, 3, 3, 6}; compare = {33, 4, 6}; replace = {0, 3}; Join[Complement[initial, compare], replace] {1, 2, 3, 0, 3} will do what you want or give you an idea of how to proceed. -- To reply via email subtract one hundred and four