Inverse match on ets?
Ulf Wiger (AL/EAB)
ulf.wiger@REDACTED
Mon Oct 10 14:45:16 CEST 2005
Apologies. I replied before fully understanding what you were after.
Ok, so how about this?
1> ets:new(filters, [public,named_table]).
filters
2> ets:insert(filters, {pid(0,56,0), {record,a,'_'},[], [true]}).
true
3> ets:insert(filters, {pid(0,57,0), {record,b,'_'},[], [true]}).
true
4> ets:insert(filters, {pid(0,62,0), {record,'_',7},[], [true]}).
true
5> catch ets:foldl(fun({Pid,MS,G,R}, Acc) -> [{Pid,ets:test_ms({record,a,7},[{MS,G,R}])}|Acc] end, [], filters).
[{<0.62.0>,{ok,true}},{<0.57.0>,{ok,false}},{<0.56.0>,{ok,true}}]
/Uffe
> -----Original Message-----
> From: Tim Bates [mailto:tim@REDACTED]
> Sent: den 10 oktober 2005 14:30
> To: Ulf Wiger (AL/EAB)
> Cc: erlang-questions@REDACTED
> Subject: Re: Inverse match on ets?
>
>
> Ulf Wiger (AL/EAB) wrote:
> > Here's an example, but it depends a bit on how generic you
> want the function to be.
>
> Thanks Ulf, but I was hoping for something a lot more general
> than that.
> I want processes to be able to register their interest in a
> particular
> type of message, and the messages are somewhat free-form.
>
> I guess another way to do it, that I'll fall back on, is to have a
> callback function for each process and use Erlang's compiled
> pattern-matching to select the messages I'm interested in.
>
> Tim.
>
> --
> Tim Bates
> tim@REDACTED
>
More information about the erlang-questions
mailing list