ets question

Chandrashekhar Mullaparthi <>
Tue May 10 05:38:12 CEST 2005


Serge,

The MatchSpec should be slightly different for select_delete to work. 
Instead of

[{{1,2},[],['$_']}]

which is the result of the ets:fun2ms/1 call you have, the MatchSpec 
should look like this:

[{{1,2},[],[true]}]

12> ets:new(a, [named_table]).
a
13> true = ets:insert(a, {1,2}).
true
14> ets:select_delete(a, [{{1,2},[],[true]}]).
1

cheers
Chandru

On 9 May 2005, at 21:49, Serge Aleynikov wrote:

> Hi All,
>
> I have the following question about ets:select_delete().  What do you 
> think this function t() should return?
>
> -include_lib("stdlib/include/ms_transform.hrl").
>
> t() ->
>     a = ets:new(a, [named_table]),
>     true = ets:insert(a, {1,2}),
>     M = ets:fun2ms(fun({1,2}) -> object() end),
>     [{1,2}] = ets:select(a, M),
>     ets:select_delete(a, M).
>
> I would expect it to return 1, yet it returns 0.  What am I missing?
>
> Thanks.
>
> Serge
>




More information about the erlang-questions mailing list