作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
假设我有一个 ets 表,例如:
I = ets:new(mytable, [named_table, set]).
ets:insert(I, {10,{10, 4 ,"description"}).
我想使用 ets:update_counter
更新元素 4
。
我尝试了不同的方式,但找不到解决方案,例如:
ets:update_counter(I, 10 , {3,1}).
** exception error: bad argument
in function ets:update_counter/3
called as ets:update_counter(mytable,10,{3,1})
我想要的结果是:
{10,{10, 5 ,"description"}
最佳答案
我建议仅使用一个元组作为键和值,而不是使用一个元组作为另一个元组中的值:
1> I = ets:new(mytable, [named_table, set]).
mytable
2> ets:insert(I, {10, 10, 4 ,"description"}).
true
3> ets:update_counter(I, 10 , {3,1}).
5
4> ets:lookup(I, 10).
[{10,10,5,"description"}]
关于erlang - 如何更新 ets 表中存储的元组内的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48022551/
我是一名优秀的程序员,十分优秀!