[erlang-questions] In what order are pattern matching clauses evaluated?

Gunilla Arendt <>
Tue Feb 20 10:22:01 CET 2007


Have you checked out the Erlang Reference Manual?
http://www.erlang.org/doc/doc-5.5.3/doc/reference_manual/part_frame.html
(Chapter 5.2 Function Evaluation).

Regards,
Gunilla

Seth Warn wrote:
> Hello,
> 
> While trying out Erlang, I noticed the following factorial function works:
> 
> fac(N) when N > 0 ->
>     N * fac(N-1);
> fac(0) -> 1.
> 
> "Ah ha," I said, "the pattern matching is not strictly top-down."  Is
> there a resource somewhere that describes how the clauses may/will be
> rearranged?  Searching the archive, the closest thing I found was this
> post, which says that the clauses will be grouped by type:
> 
> http://www.erlang.org/pipermail/erlang-questions/2000-May/001267.html
> 
> Thanks,
> 
> Seth Warn
> University of Kansas
> 
> 




More information about the erlang-questions mailing list