Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: List element replacement.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52063] Re: [mg51980] List element replacement.
  • From: János <janos.lobb at yale.edu>
  • Date: Tue, 9 Nov 2004 01:36:57 -0500 (EST)
  • References: <200411060707.CAA25986@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Nov 6, 2004, at 2:07 AM, Robert G. Wilson v wrote:

> Et al,
>
> 	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

remove from 'initial' or from 'compare' ?
>  and put in the elements from
> the 'replace' list.

put into 'initial' or 'compare' ?

You have to be more specific.

In[17]:=
(Length[Position[init,
      #1]] & ) /@ comp

will give you a list indicating how many times an element from comp was 
found in init.

In[16]:=
MemberQ[
   (Length[Position[init,
       #1]] & ) /@ comp, 0]

will give true if there was minimum one member of comp not in init.  If 
it gives false then all members of comp was in init so then you can go 
ahead with the replacements.

I hope it helps.

János
>
> Thank you in advance,
>
> Bob.
>
>
----------------------------------------------
Trying to argue with a politician is like lifting up the head of a 
corpse.
(S. Lem: His Master Voice)


  • Prev by Date: Re: Variance
  • Next by Date: Re: Mathematica Categorization - Humor
  • Previous by thread: Re: List element replacement.
  • Next by thread: Re: List element replacement.