[erlang-questions] Pattern-matching function?

Michael Radford mrad-direct-erlang@REDACTED
Wed Oct 29 17:22:31 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



More information about the erlang-questions mailing list