RE: Lists to mask other lists
- To: mathgroup at smc.vnet.net
- Subject: [mg19102] RE: [mg19022] Lists to mask other lists
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Thu, 5 Aug 1999 01:35:18 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Aram Schiffman wrote: ------------------------- I am trying to use one list to control the content of a second list. (It's not really masking, but...) Here's what I mean. Let's say maskList={1,0,0,1,1} realDealList={aaa,bbb,ccc,ddd,eee} (* could be filled with anything; same # elements as maskList } If a 1 appears at position n of maskList, then I leave the corresponding element of realDealList alone. But if a 0 appears, then I want to change the corresponding element of realDealList in some prescribed way. Let's say I change those elements to my first name (aram). Then realDealList would become {aaa,aram,aram,ddd,eee} ------------------------- The following should work nicely. In[1]:= MaskList={1,0,0,1,1}; realDealList={aaa,bbb,ccc,ddd,eee}; ReplacePart[realDealList,"aram",Position[MaskList,0]] Out[3]= {aaa,aram,aram,ddd,eee} ----------- Regards, Ted Ersek