Developing @lucas Ross answer:
You make it on a one line command :
distinct_tuples = [for k, v in { for t in <your_tuples> : t.a => t... } : v[0]]
Explanation:
The first loop will group by each tuple that have the same "a" attribute. This is done using ... symbol. You will have the following Map of objects:
map = {
"1" = [
{
a = 1
b = 2
},
{
a = 1
b = 3
},
]
"5" = [
{
a = 5
b = 4
},
]
}
for the second loop, it will flatten the map created previously and selects only the first value. you will get the following object:
[
{
a = 1
b = 2
},
{
a = 5
b = 4
},
]
references: