[erlang-questions] ets:match_delete

Anthony Ramine <>
Tue Jun 7 19:35:21 CEST 2011


Le 7 juin 2011 à 19:26, Anthony Ramine a écrit :

> Le 7 juin 2011 à 19:15, Roberto Ostinelli a écrit :
> 
>> 2011/6/7 Anthony Ramine <>
>> 
>> [{{'_','$1','_','_'},[{'>','$1',2}],[]}] should work. You put a list instead of a tuple for the match argument.
>> By the way I didn't read the doc to figure it out, I just did ets:fun2ms(fun ({_,X,_,_}) when X > 2 -> X end),
>> which is pretty good for figuring out how to write matchspecs.
>> 
>> hi anthony,
>> 
>> no this does not work.
>> 
>> furthermore, i took the list format from the 2nd example provided in the docs:
>> http://www.erlang.org/doc/apps/erts/match_spec.html#id71596
>> 
>> thank you anyway :)
>> 
>> r.
> 
> My bad then, ets:match_delete must behave differently than lookup then, because this works:
> 
> 	ets:test_ms({a, 3, b, c}, [{{'_', '$1', '_', '_'},[{'>', '$1', 2}],['it works!']}])
> 

Oh ok I understand, I didn't know what to return in the fun from my ets:fun2ms/1 call. It should have returned true,
thus making the last ms component as [true]. Then you end up with the same thing as Tobias :)

--
Anthony Ramine
Dev:Extend
http://dev-extend.eu







More information about the erlang-questions mailing list