MathGroup Archive 1998

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

Search the Archive

Re: lists



In article <69nc3r$8bh@smc.vnet.net>, Paul.Hanson@colorado.edu wrote:

> Hola!
>   So, if you have a couple of lists:
>   {{1},{2},{3},{4}....{n}}
> and
>   {{1a},....{na}}
> and I want to combine them such that,
>   {{1},{1a},{2},{2a}....{n},{na}}
> 
> How do I get there?  Thanks in advance for the help.
> 
> Paul Hanson
> 
> -- 
>                                  * * 
>                                 *    *
>                            /\    */\*
>                           /  \   /  \ /\


An example that shows the way to the general solution:


In[1]:=
temp1={{1},{2},{3},{4}}

Out[1]=
{{1},{2},{3},{4}}

In[2]:=
temp2={{a1},{a2},{a3},{a4}}

Out[2]=
{{a1},{a2},{a3},{a4}}

In[3]:=
Transpose[{temp1,temp2}]

Out[3]=
{{{1},{a1}},{{2},{a2}},{{3},{a3}},{{4},{a4}}}

In[4]:=
Flatten[Transpose[{temp1,temp2}],1]

Out[4]=
{{1},{a1},{2},{a2},{3},{a3},{4},{a4}}

-- 
David Reiss
dreissNOSPAM@nospam.earthlink.net
http://home.earthlink.net/~dreiss
To send personal email, remove the words  "nospam" and "NOSPAM" from the
email address



  • Prev by Date: small typo "in The Book"
  • Next by Date: mathematica V 2.2 win95
  • Prev by thread: Re: lists
  • Next by thread: Re: lists