MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: List element replacement.

  • To: mathgroup at
  • Subject: [mg52016] Re: List element replacement.
  • From: Bill Rowe <readnewsciv at>
  • Date: Sun, 7 Nov 2004 01:03:39 -0500 (EST)
  • Sender: owner-wri-mathgroup at

On 11/6/04 at 2:07 AM, rgwv at (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

  • Prev by Date: Re: Notebook output write to a different file
  • Next by Date: Re: List element replacement.
  • Previous by thread: Re: List element replacement.
  • Next by thread: Re: List element replacement.