Find all occurrences of {1, _}
; in other words, all first element values that are 1 from each tuple in the list.
Consider the following input:
[
{1, 0},
{2, 2},
{1, 1},
{11, 1},
{1, 3},
{1, 2},
{13, 1}
]
Expected Output:
[{1,0}, {1,1}, {1,3}, {1,2}]
I tried Enum.find(tl(input), fn x -> elem(x, 0) == elem(hd(input), 0) end)
, but I realized that Enum.find/2
only returns the first and only one element that matches the criteria or function, which is: {1,1}
.
My goal is to find all tuples that contain {1, _}
, where the first element must be 1 and the second element can be any value.