Permalink
Browse files

Mention maps operations happen in arbitrary order

Note the `maps:foldl/3` and `maps:foldr/3` were removed in favor
of `maps:fold/3`, since iteration happens in arbitrary order.
  • Loading branch information...
josevalim authored and psyeugenic committed Jan 21, 2014
1 parent 81fc8d4 commit eb877f35c6e73cdef0ab0e725bdbbcae012fbbb9
Showing with 7 additions and 42 deletions.
  1. +7 −42 eeps/eep-0043.md
View
@@ -488,7 +488,7 @@ Richard O'Keefes frames proposal.
Syntax equivalence: `[K || K := _ <- M]`.
- Returns a complete list of Keys, in sorted order, which resides within
+ Returns a complete list of Keys, in arbitrary order, which resides within
map `M`.
Same as, `[K || {K,_} <- maps:to_list(M)]`.
@@ -501,30 +501,18 @@ Richard O'Keefes frames proposal.
contains key `K`. If no value is associated with key `K` then the function
will return `error`.
-##### `maps:foldl(F :: fun((K :: term(), V :: term(), In :: term()) -> Out :: term()), A :: term(), M :: map()) -> Result :: term().`
+##### `maps:fold(F :: fun((K :: term(), V :: term(), In :: term()) -> Out :: term()), A :: term(), M :: map()) -> Result :: term().`
Syntax equivalence: *none*
Calls `F(K, V, In)` for every key `K` to value `V` association in map `M` in
- ascending key order. The function fun `F/3` must return a new accumulator
- which is passed to the next successive call. `maps:foldl/3` returns the final
+ arbitrary order. The function fun `F/3` must return a new accumulator
+ which is passed to the next successive call. `maps:fold/3` returns the final
value of the accumulator. The initial accumulator value `A` is returned if
the map is empty.
Same as, `lists:foldl(fun({K,V}, In) -> F(K,V,In) end, A, maps:to_list(M))`.
-##### `maps:foldr(F :: fun((K :: term(), V :: term(), In :: term()) -> Out :: term()), A :: term(), M :: map()) -> Result :: term().`
-
- Syntax equivalence: *none*
-
- Calls `F(K, V, In)` for every key `K` to value `V` association in map `M` in
- descending key order. The function fun `F/3` must return a new accumulator
- which is passed to the next successive call. `maps:foldr/3` returns the final
- value of the accumulator. The initial accumulator value `A` is returned if
- the map is empty.
-
- Same as, `lists:foldr(fun({K,V}, In) -> F(K,V,In) end, A, maps:to_list(M))`.
-
##### `maps:from_list([{K1,V1}, .., {Kn,Vn}]) -> M :: map().`
Syntax equivalence: `#{ K1 => V1, .., Kn => Vn }`
@@ -583,8 +571,7 @@ Richard O'Keefes frames proposal.
Syntax equivalence: `[{K, V} || K := V <- M]`.
- Where the pairs, `[{K1,V1}, ..., {Kn,Vn}]`, are returned in a sorted order.
- The Map ordering is described later in this document.
+ Where the pairs, `[{K1,V1}, ..., {Kn,Vn}]`, are returned in arbitrary order.
##### `maps:update(K :: term(), V :: term, M0 :: map()) -> M1 :: map()`
@@ -600,7 +587,7 @@ Richard O'Keefes frames proposal.
Syntax equivalence: `[V || _ := V <- M]`.
- Returns a complete list of values, in key sorted order, contained in map `M`.
+ Returns a complete list of values, in arbitrary order, contained in map `M`.
Same as, `[V || {_,V} <- maps:to_list(M)]`.
@@ -688,12 +675,7 @@ Example:
false
-Maps are printed with keys in Erlang term order.
-
-Example:
-
- > #{ c => 3, b => 2, a => 1 }.
- #{ a => 1, b => 2, c => 3 }
+Maps are printed with keys in arbitrary order.
Operator Precedence
@@ -1363,23 +1345,6 @@ namely numbers. In the case of a Maps, `true = #{ 1.0 => V } == #{ 1 => V}`.
`N1 = maps:size(M1) and N2 = maps:size(M2)`
-The discussion and results on equality versus matching for keys stems from ets
-and ordered set.
-
-Consider the following with ets.
-
- 1> ets:new(foo, [named_table, ordered_set]).
- foo
- 2> ets:insert(foo, {1,v1}).
- true
- 3> ets:insert(foo, {1.0,v2}).
- true
- 4> ets:lookup(foo,1).
- [{1.0,v2}]
- 5> ets:match(foo, ets:fun2ms(fun({1,V}) -> V end)).
- []
-
-
Accessing a single value
------------------------

0 comments on commit eb877f3

Please sign in to comment.