-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
map (apply function to each element in a table) :dets.traverse/2 | :ets.??? fun2ms + select_replace
This might be a little tricky... see the filter/2 and reject/2 functions....
You can see from this example that the operation could modify both keys and values -- this would mean deleting entries from the table entirely.
iex> m = %{"a" => 1, "b" => 2, "c" => 3}
%{"a" => 1, "b" => 2, "c" => 3}
iex> Enum.map(m, fn {k, v} -> {String.upcase(k), v + 1} end) |> Enum.into(%{})
%{"A" => 2, "B" => 3, "C" => 4}
What should happen if the supplied function does not return a {key, value} tuple? What if it only SOMETIMES returns the proper response? Should the operation return an error? There's no way to "roll back" the operation, so this could mean that you end up mangling your table. Maybe a map!/2 name might be more appropriate and we could just let the error be raised (presumably because the {k, v} pattern wasn't matched.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request