Keyword.replace_lazy/3

defmodule Keyword do
  def replace_lazy(keywords, key, fun)
end

Replaces the value under key using the given function only if the key already exists in keywords.

In case the key exists multiple times in the keyword list, it removes later occurrences.

If key is not present keywords is returned as it.