[erlang-questions] Pattern-matching function?

Francois De Serres fdeserres@REDACTED
Wed Oct 29 15:00:08 CET 2008

Hi there.

I need a function that actually does pattern matching: pm(Tuple, Pattern)->MatchedPattern|error
> pm({a,b,c}, {a,X,Y}).
> pm({a,b,c}, {b,X,Y}).
{error, badmatch}
> pm({a,b,c}, {a,X}).
{error, badmatch}

This trivial code works only with the empty tuple/pattern :
pm(T,P) ->
    P = T, P.
because pattern variables (X, Y) are unbound at function call.

I tried to find a hint in the libs with no avail.
If anyone has a lead, can you please put me on track?


"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail

More information about the erlang-questions mailing list