[erlang-questions] Pattern-matching function?

Francois De Serres <>
Wed Oct 29 20:20:21 CET 2008


Seems like the one, will try it.
Thanks Much.
--
François

> ets:match_spec_run/2 allows you to run the match spec against a list of
> tuples.
> 
> Mike
> 
> Francois De Serres writes:
> > > Richard Carlsson writes:
> > > > Francois De Serres wrote:
> > > > > I need a function that actually does pattern matching: pm(Tuple,
> > > Pattern)->MatchedPattern|error
> > > > 
> > > > You cannot pass a pattern with uninstantiated variables to a
> function.
> > > > Erlang is a strict functional language, it is not Prolog. Patterns
> are
> > > > not run-time values.
> > > 
> > > But maybe he can do what he wants with match specs?  They're much more
> > > cumbersome than pattern matching, but they are more or less a run-time
> > > representation of a pattern.
> > > 
> > > See ets:match_spec_run/2 and other mentions of match specs in the ets
> > > manpage.  Also this page:
> > > http://www.erlang.org/doc/apps/erts/match_spec.html
> > > 
> > > Mike
> > 
> > Thanks Mike,
> > Nice, but ets:select/2 means the tuple to match against would have to be
> in a table, or...?
> > --
> > Francois


-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail



More information about the erlang-questions mailing list