[erlang-questions] ets:match_delete

Tobias tobias.rodaebel@REDACTED
Tue Jun 7 18:01:03 CEST 2011


I guess the problem here is, that ets:match_delete/2 takes a pattern as second argument while ets:select_delete/2 wants a match_spec(). But maybe I'm mixing things up myself...

On Jun 7, 2011, at 5:43 PM, Tobias wrote:

> Hi Roberto,
> 
> have you tried
> 
> N = ets:select_delete(test, [{{'$1', '$2', '$3', '$4'}, [{'>', '$2', 2}], [true]}]),
> 
> instead?
> 
> Cheers,
> Tobias
> 
> On Jun 7, 2011, at 5:33 PM, Roberto Ostinelli wrote:
> 
>> dear list,
>> 
>> i'm trying to match delete elements from an ETS table which have one of the tuple elements greater than 2.
>> 
>> start() ->
>>    ets:new(test, [named_table, set, protected]),
>>    ets:insert(test, {a, 1, true, true}),
>>    ets:insert(test, {b, 2, true, true}),
>>    ets:insert(test, {c, 3, true, true}),
>>    ets:insert(test, {d, 2, true, true}),
>>    ets:insert(test, {e, 1, true, true}),
>>    ets:match_delete(test, [{['_', '$1', '_', '_'], [{'>', '$1', 2}], []}]),
>>    Result = ets:tab2list(test),
>>    ets:delete(test),
>>    Result.
>> 
>> this however does return the whole table.
>> 
>> any hints on what i'm doing wrong?
>> 
>> r.
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
> 




More information about the erlang-questions mailing list