MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Transpose to multiple lists


 

>-----Original Message-----
>From: konstantpi at mail15.com [mailto:konstantpi at mail15.com] 
To: mathgroup at smc.vnet.net
>Sent: Tuesday, April 05, 2005 9:21 AM
>Subject: [mg55761] [mg55735] Transpose to multiple lists
>
>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
>
Don't understand, what's concise, what's dumby?


>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.
>
>
To explore your idea use Map:

Join @@ Map[Transpose[{Range[Length[#1]], #1}] &, lst]


To mark the elements MapIndex may do:

Join @@ MapIndexed[{Last[#2], #1} &, lst, {2}]


--
Hartmut Wolf




  • Prev by Date: Re: mathlink and cygwin
  • Next by Date: Re: 3D graphics domain
  • Previous by thread: Re: Transpose to multiple lists
  • Next by thread: Re: Transpose to multiple lists