[英]Using ETS Select To Form An Intersection
i have the following ets structure: 我有以下ets结构:
SomeTable = ets:new(sometable, [bag]).
ets:insert(SomeTable, [
{set1,item1},
{set1,item2},
{set1,item3},
{set2,item1},
{set2,item2},
{set2,item4}]).
i want to get intersection of set1 and set2 using ets:select and fun2ms, result will be [item1, item2]. 我想使用ets:select和fun2ms获得set1和set2的交集,结果将是[item1,item2]。
i spent hours and hours trying to accomplist it with ets:select and fun2ms with no success. 我花了几个小时试图用ets:select和fun2ms来完成它,但是没有成功。 can you help me out using ets:select and fun2ms? 您可以使用ets:select和fun2ms帮助我吗?
thanks for all answers! 感谢所有答案!
ps: i know about sets module, but i have to use ets and this exact data structure. ps:我知道集合模块,但是我必须使用ets和这个确切的数据结构。
qlc:e(qlc:q([ I || {set1, I} <- ets:table(sometable), ets:match_object(sometable, {set2, I}) =/= []])).
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.