Re: Best code to match corresponding list items?
- To: mathgroup at smc.vnet.net
- Subject: [mg27747] Re: Best code to match corresponding list items?
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Wed, 14 Mar 2001 04:06:46 -0500 (EST)
- References: <98kobb$pp6@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Roger: A={a1,a2,a3,a4}; B={b1,b2,b3,b4}; Transpose[{A,B}] {{a1,b1},{a2,b2},{a3,b3},{a4,b4}} and back: Transpose[%] {{a1,a2,a3,a4},{b1,b2,b3,b4}} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Roger Ison" <rison at ix.netcom.com> wrote in message news:98kobb$pp6 at smc.vnet.net... > Given two lists > A={a1,a2,a3,...} > B={b1,b2,b3...} > > I want to produce the list > C={ {a1,b1}, {a2,b2}, {a3,b3}...} } > as efficiently as possible. > Better yet, generalize to do this with N lists all of same length. > > Obviously it can be done directly with Table, but is there a more elegant, > implicit way to write it that doesn't involve passing a function to Table > and using an explicit index? Is there a general functional primitive for > this that I simply haven't found? Seems like something so common, there > ought to be a built-in function for it. > > Thanks, > Roger > > >