[erlang-questions] Pattern-matching function?

Francois De Serres <>
Wed Oct 29 19:45:43 CET 2008


> 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


-- 
GMX Download-Spiele: Preizsturz! Alle Puzzle-Spiele Deluxe über 60% billiger.
http://games.entertainment.gmx.net/de/entertainment/games/download/puzzle/index.html



More information about the erlang-questions mailing list