Re: Transpose to multiple lists
- To: mathgroup at smc.vnet.net
- Subject: [mg55769] Re: Transpose to multiple lists
- From: "Valeri Astanoff" <astanoff at yahoo.fr>
- Date: Wed, 6 Apr 2005 03:10:58 -0400 (EDT)
- References: <d2tf20$qk8$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Seems convenient to use MapIndexed.
Let me first reply to the second question
because the first question is just
a particular case of the second question:
In[1]:= lst = {{4,6,3},{6,8,7,3},{9,4}};
In[2]:= MapIndexed[{First[#2],#1}&,#]& /@ lst // Flatten[#,1]&
Out[2]= {{1,4},{2,6},{3,3},{1,6},{2,8},{3,7},{4,3},{1,9},{2,4}}
In[3]:= a = {3,6,3,2}; b = {9,8,7,6};
In[4]:= MapIndexed[{First[#2],#1}&,#]& /@ {a,b} // Flatten[#,1]&
Out[4]= {{1,3},{2,6},{3,3},{4,2},{1,9},{2,8},{3,7},{4,6}}
hth
Valeri