multiple patterns per clause?
Tue Aug 29 10:31:26 CEST 2006
You could group the clauses a bit:
case L of
[L1|_] when L1 =:= $f; L1 =:= $x ->
On Mon, Aug 28, 2006 at 10:47:38AM -0400, Yariv Sadan wrote:
> 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
> [$x|_] ;
> [$a, $b, $c | _] ->
> _ ->
> I know the above is illegal, so what's the easiest way of doing
> something similar in Erlang?
> Thanks in advance,
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions