Combining three arrays of same size

I have three arrays of numbers. I want to combine them so they become a list of maps. Here’s my attempt:

    for %{members: members, ratings: ratings, ranks: ranks} <- expanded_group,
        {id, rating, rank} <-, ratings, ranks),
        # Create result value
         do: %{member_id: id, rating: rating, rank: rank}

But it doesn’t work because zip only takes two arguments.

expanded_group looks like:

      %{count: 2, members: [1, 4], group_rating: 13, ratings: [8, 5], ranks: [0,0]},
      %{count: 1, members: [2], group_rating: 6, ratings: [6], ranks: [1]},
      %{count: 1, members: [3], group_rating: 7, ratings: [7], ranks: [2]}

You want, which takes a list of Enumerables:

{id, rating, rank} <-[members, ratings, ranks]),
1 Like