List.keystore/4

defmodule List do
  def keystore(list, key, position, new_tuple)
end

Receives a list of tuples and replaces the element identified by key at position with new_tuple.

If the element does not exist, it is added to the end of the list.