Re: lists
- To: mathgroup@smc.vnet.net
- Subject: [mg10538] Re: lists
- From: Bruce Wolk <bawolk@ucdavis.edu>
- Date: Tue, 20 Jan 1998 02:23:24 -0500
- Organization: University of California, Davis
- References: <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
>
> --
> * *
> * *
> /\ */\*
> / \ / \ /\
Using Flatten and Transpose will work.
In[2]:=
a={{1},{2},{3},{4}}
Out[2]=
{{1},{2},{3},{4}}
In[3]:=
b={{a1},(a2),{a3},{a4}}
Out[3]=
{{a1},a2,{a3},{a4}}
In[4]:=
Flatten[Transpose[{a,b}],1]
Out[4]=
{{1},{a1},{2},a2,{3},{a3},{4},{a4}}
Bruce Wolk