multiple patterns per clause?

David Hopwood david.nospam.hopwood@REDACTED
Mon Aug 28 17:50:49 CEST 2006


Yariv Sadan wrote:
> 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

What would this construct mean, if the body expression refers to a variable
that is bound in some of the alternative patterns but not all of them?

-- 
David Hopwood <david.nospam.hopwood@REDACTED>





More information about the erlang-questions mailing list