Take the 2-minute tour ×  For functions where the ordering of
the clauses is unimportant, is it base case last:  all(Pred,
[Head|Tail]) ->   case Pred(Head) of     true -> all(Pred,
Tail);     false -> false all(Pred, []) when is_function(Pred,
1) -> true.  Or base case first:  all(Pred, [Head|Tail]) ->
case Pred(Head) of     true -> all(Pred, Tail);     false ->
false  From looking at the source code in the standard library,
it seems the convention is base case last. Is that the preferred
style? Is there a reason for it, or is it just the way it is?
share|improve this question  3 Answers 3  Only the second case
will work, as cases are matched in order.  Since the integer 0
is able to match the pattern N, the constant 0 clause would
never be reached if it came after.  It is that ordered aspect of
pattern-matching which you should think about when writing
function clauses, case clauses, or any other such sequence of
potential matches.  share|improve this answer Whoops, sorry that
was a bad example, I meant