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


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

Re: How to create this kind of list

Started byTomas Garza <tgarza10@msn.com>
First post2011-10-16 11:09 +0000
Last post2011-10-16 11:09 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#5666 — Re: How to create this kind of list

FromTomas Garza <tgarza10@msn.com>
Date2011-10-16 11:09 +0000
SubjectRe: How to create this kind of list
Message-ID<j7ee0g$ehs$1@smc.vnet.net>
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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web