       RE: List operation

• To: mathgroup at smc.vnet.net
• Subject: [mg45641] RE: [mg45617] List operation
• From: "Kieng" <Sorasak at brown.edu>
• Date: Fri, 16 Jan 2004 19:57:49 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Here is a way to do it.
a = {x, y, z};
b = {X, Y, Z};
Map[{a[[#]], b[[#]]} &, Range[1, Length[b]]]
The result is
{{x, X}, {y, Y}, {z, Z}}.

Sorasak
-----Original Message-----
From: Dr. Wolfgang Hintze [mailto:weh at snafu.de]
To: mathgroup at smc.vnet.net
Subject: [mg45641] [mg45617] List operation

Given two lists

In:=
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:=
paarweise[x_, y_, n_] := Table[{x[[i]], y[[i]]}, {i, 1, n}]

gives

In:=
z = paarweise[x, y, 3]

Out=
{{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

```

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