Re: Transpose to multiple lists

*To*: mathgroup at smc.vnet.net*Subject*: [mg55771] Re: Transpose to multiple lists*From*: dh <dh at metrohm.ch>*Date*: Wed, 6 Apr 2005 03:11:00 -0400 (EDT)*References*: <d2tf20$qk8$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Konstant, here is a short, but cryptic solution: t={{2, 3}, {1, 2, 3}}; Flatten[ (i = 1; {i++, #} & /@ #) & /@ t , 1] Out:{{1, 2}, {2, 3}, {1, 1}, {2, 2}, {3, 3}} Explenation: We are using two nested pure function: The inner one f1: {i++,#}& replaces every Integer by a list of {Index,Integer} and increments the index. The outer one f2: (i=1; f1 /@ #)& resets the index to 1 and then maps f1 to its argument (This will be a single list of integers.) f2 is then mapped to the list of list of integers. Because we now have an additional level in the nesting of lists, like: {{{1, 2}, {2, 3}}, {{1, 1}, {2, 2}, {3, 3}}} we remove the superflous nesting by Flatten. Sincerely, Daniel konstantpi at mail15.com wrote: > First Q:Transpose to multiple lists > a={3,6,3,2} > b={9,8,7,6} > Join[Transpose[{Range[Length[a]], a}],Transpose[{Range[Length[b]], b}]] > > Out[]={{1, 3}, {2, 6}, {3, 3}, {4, 2}, {1, 9}, {2, 8}, {3, 7}, {4, 6}} > what are the concise solutions other than this dumby solution > > Second Question: transposing Range to every sublist > lst={{4,6,3},{6,8,7,3},{9,4}} > how could i obtain the output: > {{1,4},{2,6},{3,3},{1,6},{2,8},{3,7},{4,3},{1,9},{2,4}} > thanks > konstant. >