MathGroup Archive 2004

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

Search the Archive

AW: Simple list operation


Hello Wolfgang,

try:

x = {a, b, c};
y = {A, B, C};
Partition[Sort[Join[x, y]], 2]

Output:

{{a, A}, {b, B}, {c, C}}

Best regards,
Matthias Bode
Sal. Oppenheim jr. & Cie. KGaA
Koenigsberger Strasse 29
D-60487 Frankfurt am Main
GERMANY
Tel.: +49(0)69 71 34 53 80
Mobile: +49(0)172 6 74 95 77
Fax: +49(0)69 71 34 95 380
E-mail: matthias.bode at oppenheim.de
Internet: http://www.oppenheim.de



-----Ursprüngliche Nachricht-----
Von: Dr. Wolfgang Hintze [mailto:weh at snafu.de]
Gesendet: Freitag, 16. Januar 2004 12:05
An: mathgroup at smc.vnet.net
Betreff: [mg45579] Simple list operation


Given two lists

In[10]:=
x = {a, b, c};

In[11]:=
y = {A, B, C};

how can I get the list of pairs

p={{a,A},{b,B},{c,C}}?

I have used a brute force method like

In[9]:=
p = Table[ {x[[i]], y[[i]]}, {i, 1, 3}]

Out[9]=
{{a, A}, {b, B}, {c, C}}

but I'm sure there is a much more elegant way.
Any hint is greatly appreciated.

Wolfgang


  • Prev by Date: Fwd: using functions with package name prefixed.
  • Next by Date: Re: using functions with package name prefixed.
  • Previous by thread: jlink function argument
  • Next by thread: Script, Gothic and DoubleStruck Characters