MathGroup Archive 2004

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

Search the Archive

Re: List operation


On Friday, January 16, 2004, at 05:05 AM, Dr. Wolfgang Hintze wrote:

> Given two lists
>
> In[7]:=
> x = {a, b, c}
> y = {A, B, C}
>
> I'm looking for the list of pairs
>
> z = {{a, A}, {b, B}, {c, C}}
>
> Defining the function
>
> In[5]:=
> paarweise[x_, y_, n_] := Table[{x[[i]], y[[i]]}, {i, 1, n}]
>
> gives
>
> In[6]:=
> z = paarweise[x, y, 3]
>
> Out[6]=
> {{a, A}, {b, B}, {c, C}}
>
> I'm sure there is a more elegant way to get such a list of pairs.
> Any help is appreciated.
>
> Wolfgang Hintze

Like this:

{x,y}//Transpose
==========
Hugh Walker
Gnarly Oaks


  • Prev by Date: Re: List operation
  • Next by Date: Re: Simple list operation
  • Previous by thread: Re: List operation
  • Next by thread: Re: List operation