[Date Index] [Thread Index] [Author Index]
Re: List element replacement.
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:= (Length[Position[init, #1]] & ) /@ comp will give you a list indicating how many times an element from comp was found in init. In:= 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)