简体   繁体   中英

Erlang: Find intersections in a ets table

I have an ets with the next items:

[at, {other_place}, me],
[other_place, {place}, {other_place}]],
[at, {place}, me], 
[on, {surface}, {object}],
[small, {object}]

And I have the list [[at, door, me],[on, floor, chair],[small, bannanas]]

I need to compare every item in the ets table to an item in the list and if the first one is the same atom, replace the items in round brackets. So if I have [at, door, me] , it matches with [at, {other_place}, me] , I have to change {other_place} for the atom door in all the ets table.

I think this can be accomplished with ets:foldl by passing list to be compared to as an Acc argument.

If necessary list can also be folded with lists:foldl if you need to go through it's sublists.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM