hope
hope copied to clipboard
Define and implement dictionary methods for manipulation of nested values
Something along the lines of:
-spec get_path(t(K, Elt), Path :: [K]) ->
{ok, Elt}
| {error, {not_found, K}}
when Elt :: {leaf, V} | {node, t(K, Elt)}
.
-spec set_path(t(K, Elt)), Path :: [K], Elt) ->
{ok, t(K, Elt)}
| {error, {not_found, K}}
when Elt :: {leaf, V} | {node, t(K, Elt)}
.
When a nonexistent node is encountered during a set
operation, should it be created or should we exit with an error? Should either behavior just be an option?