Interleave 2单个dim列表到列表列表中

时间:2013-04-16 00:00:13

标签: wolfram-mathematica

我有2个列表,{1,2,3,4,5}{a,b,c,d,e}。我希望最终得到{{1,a},{2,b},{3,c},{4,d},{5,e}}

1 个答案:

答案 0 :(得分:0)

这个怎么样:

l1 = {1, 2, 3, 4, 5};
l2 = {a, b, c, d, e};

Partition[Riffle[l1, l2], 2]
{{1, a}, {2, b}, {3, c}, {4, d}, {5, e}}

或者,您可以尝试

l1 = {1, 2, 3, 4, 5};
l2 = {a, b, c, d, e};

Transpose[{l1, l2}]
{{1, a}, {2, b}, {3, c}, {4, d}, {5, e}}