[erlang-questions] "Symmetrical" function

Michael Radford <>
Mon Feb 16 23:56:00 CET 2009

Richard O'Keefe writes:
> >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.
> There is the function that one *wants* to implement,
> and there is the code that has been *written* to implement half
> of it.  Michael Radford is assuming that the actually written
> code is correct ("is CORRECTLY specified").
> I'm not.  Just writing half of the clauses of
> a function and then pasting together two suitably adjusted copies
> may not give you what you expect.

So you're saying that if your code has bugs, it may not do what you
expect.  No argument there. :)

(The original poster was rather emphatic: "I have a function f(A,B) for
which f(A,B) is ALWAYS equivalent to f(B,A)".)

> He is also assuming that one of the halves of the matrix has been
> consistently chosen ("either the upper or lower half").  I didn't
> say anything in the original message to indicate that this was so.

Actually, that assumption was unnecessary.  I guess I should have said,
"when at least one of the two possible clauses for each pair of legal
patterns has been correctly specified."


More information about the erlang-questions mailing list