MathGroup Archive 2001

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

Search the Archive

Re: Best code to match corresponding list items?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27740] Re: Best code to match corresponding list items?
  • From: David Chapman <d.a.chapman at open.ac.uk>
  • Date: Wed, 14 Mar 2001 04:06:40 -0500 (EST)
  • Organization: The Open University
  • References: <98kobb$pp6@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I've done it with:

Transpose[{alist, blist}]

Generalises to

Transpose[{alist, blist, clist, dlist...}]

(It's not a good idea to use 'A, B' as your lists.  The Book says the
convention is that built-in names always start with capitals, and those you
define yourself should start with lower case.)

David



Roger Ison wrote:

> 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



  • Prev by Date: Re: Best code to match corresponding list items?
  • Next by Date: Re: Loading MultipleListPlot package
  • Previous by thread: Re: Best code to match corresponding list items?
  • Next by thread: Re: Best code to match corresponding list items?