Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5666

Re: How to create this kind of list

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!newspump.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From Tomas Garza <tgarza10@msn.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How to create this kind of list
Date Sun, 16 Oct 2011 11:09:04 +0000 (UTC)
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <j7ee0g$ehs$1@smc.vnet.net> (permalink)
References <201110151004.GAA03200@smc.vnet.net>
Lines 30
NNTP-Posting-Date 16 Oct 2011 10:12:38 GMT
NNTP-Posting-Host c24dd8b7.news.twtelecom.net
X-Trace DXC=PX?Le`oXiGXjd=H^]FJ5\ZC_A=>8kQj6]m^eQlV`f18Whn:Nb\3EacPEFiONJ7[GoVnTO>cWG1cL^
X-Complaints-To abuse@twtelecom.net
Xref x330-a1.tempe.blueboxinc.net comp.soft-sys.math.mathematica:5666

Show key headers only | View raw


I'm sure you'll get many other suggestions from the gurus in this group, but these five seem pretty obvious:
In[1]:= listA = {a1, a2, a3, a4, a5, a6}; listB = {b1, b2, b3, b4, b5, b6};
In[2]:= Transpose@{listA, listB}
Out[2]= {{a1, b1}, {a2, b2}, {a3, b3}, {a4, b4}, {a5, b5}, {a6, b6}}
In[3]:= MapThread[List, {listA, listB}]
Out[3]= {{a1, b1}, {a2, b2}, {a3, b3}, {a4, b4}, {a5, b5}, {a6, b6}}
In[4]:= Partition[Riffle[listA, listB], 2]
Out[4]= {{a1, b1}, {a2, b2}, {a3, b3}, {a4, b4}, {a5, b5}, {a6, b6}}
In[5]:= Table[{listA[[j]], listB[[j]]}, {j, 1, Length[listA]}]
Out[5]= {{a1, b1}, {a2, b2}, {a3, b3}, {a4, b4}, {a5, b5}, {a6, b6}}
--Tomas

> Date: Sat, 15 Oct 2011 06:04:15 -0400
> From: szymon.roziewski@gmail.com
> Subject: How to create this kind of list
> To: mathgroup@smc.vnet.net
>
> Hello there,
> I am thinking about creating such a list.
> I have 2 lists with the same number of elements.
> The idea is to create one list which was taken from these previous two ones
> in the following way:
> Take one element of the first list and one from another and put it into
> result list {{x1,y1},{x2,y2},...,{xn,yn}}.
> Input lists:
> A={x1,x2,...,xn}
> B={y1,y2,...,yn}
>
> All best,
> Szymon Roziewski

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How to create this kind of list Tomas Garza <tgarza10@msn.com> - 2011-10-16 11:09 +0000

csiph-web