Efficient Functional Data Structures

Klacke <>
Tue Jan 7 10:17:39 CET 2003


On Sun, Jan 05, 2003 at 06:28:03PM -0600, Eric Newhuis wrote:
> I threw out ETS perhaps prematurely (?) when I realized I couldn't match
> on variable-length keys.
> 
> In my world keys are lists of Erlang terms.  Can ETS find matches when
> some terms are don't-care?  I think the answer is yes.  But can ETS
> match on variable-length keys? I don't know the answer.
> 
> Given a set of keys such as [a,b,c], [a,b,c,d], and [a,b,c,d,e], can ETS
> find all three keys given a search pattern like [a,b,'*'] ?
> 
> I think I tried with patterns like [a,b,'_'] but that only finds [a,b,c]
> and fails to get the others.


ets:match_object(T, {[a, b | '_'] .....


a cons pattern would do the trick

/klacke


-- 
Claes Wikstrom                        -- Caps lock is nowhere and
Alteon WebSystems                     -- everything is under control          
http://www.bluetail.com/~klacke      
cellphone: +46 70 2097763



More information about the erlang-questions mailing list