将列表组合成列表理解中的元组

问题描述 投票:2回答:1
A = [ [1,2,3],[4,5,6]].
B = [ [a,b,c],[d,e,f]].

输出应该是:

[ [{1,a},{2,b},{3,c}],[{4,d},{5,e},{6,f}]].

这是我到目前为止所得到的。

输入:[[{Y} || Y <-X] || X <-A]。输出:[[{1},{2},{3}],[{4},{5},{6}]]

erlang
1个回答
2
投票

我想这就是你需要的:

[lists:zip(LA, LB) || {LA, LB} <- lists:zip(A, B)].

您需要压缩两个列表才能将它们的元素一起使用。

© www.soinside.com 2019 - 2024. All rights reserved.