erlang dict:store()与dict:append()的区别使用

本文通过示例展示了Erlang中字典(dict)模块的基本操作,包括创建空字典、插入键值对、将键值对追加到已有值上以及将字典转换为列表等常用功能。
 1 1> D0=dict:new().
 2 {dict,0,16,16,8,80,48,
 3       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
 4       {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
 5 2> D1=dict:store(a,b,D0).
 6 {dict,1,16,16,8,80,48,
 7       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
 8       {{[],[[a|b]],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
 9 3> dict:to_list(D0).
10 []
11 4> dict:to_list(D1).
12 [{a,b}]
13 5> D00=dict:new().       
14 {dict,0,16,16,8,80,48,
15       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
16       {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
17 6> D11=dict:append(a,b,D00).
18 {dict,1,16,16,8,80,48,
19       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
20       {{[],[[a,b]],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
21 7> dict:to_list(D11).
22 [{a,[b]}]
23 8> D12=dict:append(a,c,D11).
24 {dict,1,16,16,8,80,48,
25       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
26       {{[],[[a,b,c]],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
27 9> dict:to_list(D12).
28 [{a,[b,c]}]
29 

 

转载于:https://www.cnblogs.com/orez88/articles/1913605.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值