相對較晚誰以前從未解決的字典模塊,但是這似乎爲我工作:
dict:fold(fun(Key, Value, Accum) ->
[Value | Accum] end, [], D).
例子:
init() ->
Dict = dict:new(),
Dict2 = dict:append(key, value, Dict),
Dict3 = dict:append(key2, value2, Dict2),
dict:append(key3, value3, Dict3).
grab_values(D) ->
dict:fold(fun(Key, Value, Accum) ->
[Value | Accum] end, [], D).
調用:
4> D = dictfold:init().
{dict,3,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],[],
[[key2,value2]],
[[key3,value3]],
[],[],[],[],[],
[[key,value]],
[],[],[],[],[],[]}}}
5> dictfold:grab_values(D).
[[value2],[value3],[value]]