Reputation: 23
I have 2 list (can be another data type also) that represent 2 vector clocks. How can I iterate over the two list simultaneously and verified this condition: w[k] <= v[k] for each k != j, where j is a parameter?
Upvotes: 1
Views: 1460
Reputation: 222118
You're looking for Enum.zip/2
:
def check(w, v, j) do
Enum.zip(w, v)
|> Enum.with_index
|> Enum.all?(fn {{ww, vv}, k} -> k == j || ww <= vv end)
end
Upvotes: 7