Re: extract from list and keep track
- To: mathgroup at smc.vnet.net
- Subject: [mg62167] Re: extract from list and keep track
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sun, 13 Nov 2005 02:08:48 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 11/12/05 at 3:31 AM, andrea at radargift.com (Andrea) wrote: >I have a list of increasing odd numbers. I want to create a table >that indicates which numbers in this list are 1(mod 8) and 7(mod 8) >and what position in the list these numbers have. Then I would like >to have them removed form the list to get a new (reduced) list. >Example: 3, 7, 9, 21, 43, 57, 63, 71, 75, 99. I want to form this >a Table: >2 7 >3 9 >6 57 >7 63 >8 71 >7 is 7(mod 8) and is the 2nd member in the list, 9 is 1(mod 8) and >is the 3rd member in the list, etc. In[5]:= data = {3, 7, 9, 21, 43, 57, 63, 71, 75, 99}; In[6]:= Flatten@{Position[data, #][[1]], #1}]&/@ Pick[data, Mod[data, 8], 1 | 7] Out[6]= {{2, 7}, {3, 9}, {6, 57}, {7, 63}, {8, 71}} >The next list would become, having removed the ones in the table: >3, 21, 43, 75, 99 In[7]:=Pick[data, Mod[data, 8], 3 | 5] Out[7]={3, 21, 43, 75, 99} -- To reply via email subtract one hundred and four