Combining lists into tuples in list comprehension

Viewed 99
A = [ [1,2,3],[4,5,6]].
B = [ [a,b,c],[d,e,f]].

The output should be:

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

This is what I have got so far.

Input: [ [{Y} || Y<-X ] || X<-A]. Output: [[{1},{2},{3}],[{4},{5},{6}]]

1 Answers

I think this is what you need:

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

You need to zip both lists to be able to work with their elements together.

Related