[erlang-questions] "Symmetrical" function
Michael Radford
mrad-direct-erlang@REDACTED
Mon Feb 16 22:41:23 CET 2009
Richard O'Keefe writes:
> >>Note that there is a behavioural difference:
> >>the first version interleaves the swapped clauses with the
> >>originals, while the second puts all the swapped clauses
> >>after the originals. The first approach can be modified
> >>to get the effect of the second, but the second cannot
> >>_easily_ be modified to get the effect of the first.
> >
> >Can you explain some more. I don't understand the difference.
>
> Suppose we start with
>
> f(a, _) -> 1;
> f(b, _) -> 2.
But you are supposing that the function is not symmetrical.
f(a,b) =/= f(b,a).
For functions that are actually symmetrical, as the original poster was
asking about, either approach should give the same results when either
the upper or lower half of the matrix of clauses is correctly specified.
Mike
More information about the erlang-questions
mailing list