Skip to content

Instantly share code, notes, and snippets.

@sashaafm
Last active February 9, 2016 15:29
Show Gist options
  • Save sashaafm/a2924c2cb3a4b95c9189 to your computer and use it in GitHub Desktop.
Save sashaafm/a2924c2cb3a4b95c9189 to your computer and use it in GitHub Desktop.
gfe
defp gfe([]), do: nil
defp gfe(queue) do
{_, front_elem} = queue
|> Enum.group_by(fn {_, prio} -> prio end)
|> Map.to_list
|> List.last
{List.last(front_elem), queue -- [List.last(front_elem)]}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment