2013-03-03 76 views
0

有人可以給我一個關於orddict的例子:在Erlang中使用map()嗎?Erlang :: orddict的示例:map()

+0

下面是一個例子新orddict:http://erldocs.com /R15B/stdlib/orddict.html?i=24&search=orddict#update_counter/3 – Xymostech 2013-03-03 03:42:00

回答

4

orddict:地圖(F,d)適用於函數F到orddict的所有鍵/值並返回包含鍵/ NEWVALUE

1> D = orddict:new(). 
[] 
2> D1 = orddict:store(1,"test",D). 
[{1,"test"}] 
3> D2 = orddict:store(2,"test",D1). 
[{1,"test"},{2,"test"}] 
4> D3 = orddict:store(3,"test",D2). 
[{1,"test"},{2,"test"},{3,"test"}] 
5> orddict:map(fun(K,V) -> V ++ " " ++ integer_to_list(K) end, D3). 
[{1,"test 1"},{2,"test 2"},{3,"test 3"}] 
6>