multiple patterns per clause?

Yariv Sadan <>
Mon Aug 28 16:47:38 CEST 2006


Hi,

Is it possible to have a single clause match multiple patterns in Erlang?

Specifically, I want to test if a list has a number of different
prefixes, all of which would lead to the same expression.

This is what I want to write (pseudo code):

L = "foo",
case L of
  [$f|_];
  [$x|_] ;
  [$a, $b, $c | _] ->
    ok;
  _ ->
    error
end

I know the above is illegal, so what's the easiest way of doing
something similar in Erlang?

Thanks in advance,
Yariv



More information about the erlang-questions mailing list