Skip to content

Commit

Permalink
Get valid pair by priority
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Jun 12, 2024
1 parent dd20cb1 commit cda0a8a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/ex_ice/priv/checklist.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ defmodule ExICE.Priv.Checklist do
@spec get_valid_pair(t()) :: CandidatePair.t() | nil
def get_valid_pair(checklist) do
checklist
|> Enum.find({nil, nil}, fn {_id, pair} -> pair.valid? end)
|> elem(1)
|> Stream.map(fn {_id, pair} -> pair end)
|> Stream.filter(fn pair -> pair.valid? end)
|> Enum.sort_by(fn pair -> pair.priority end, :desc)
|> Enum.at(0)
end

@spec find_pair(t(), CandidatePair.t()) :: CandidatePair.t() | nil
Expand Down

0 comments on commit cda0a8a

Please sign in to comment.