[eeps] Proposal for /\ and \/ operators

Raimo Niskanen raimo+eeps@REDACTED
Thu Feb 26 10:35:58 CET 2009


On Thu, Feb 26, 2009 at 12:45:42PM +1300, Richard O'Keefe wrote:
> I'm sick of writing my own max and min functions.
> Aren't you?
> 

Yes me too...

:
> 
> Specification
> 
>     Currently the Erlang language has no built-in support for
>     the maximum and minimum operations.  So we add
> 
>     /\  with the same precedence and associativity as band
>     \/  with the same precedence and associativity as bor
> 
>     E1 /\ E2 has the same effects and value as
> 	(T1 = E1, T2 = E2, if T1 > T2 -> T2 ; true -> T1 end)
>     E1 \/ E2 has the same effects and value as
> 	(T1 = E1, T2 = E2, if T1 > T2 -> T1 ; true -> T2 end)

Can you explain to a non-mathematician (me) why you have defined
(E1 /\ E2) as min(E1, E2) and
(E1 \/ E2) as max(E1, E2). To me it seems counterintuitive
since /\ looks like a mountain hence max
and \/ looks like a valley hence min.
And I do not want to fully understand Lattice theory
to understand which operator is which. I am a simple programmer.

Since (1.0 == 1) and (1.0 >= 1) and (1 >= 1.0),
could you also for /\ and \/ elaborate on
	max(A, B) when A >= B -> A;
	max(A, B) -> B.
vs
	max(A, B) when A > B -> A;
	max(A, B) -> B.
Which may be most useful in the light of operator
precedence and binding?

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the eeps mailing list