I wrote a function which works as expected but i don't understand why the output is like that.
Function:
datatype prop = Atom of string | Not of prop | And of prop*prop | Or of prop*prop;
(* XOR = (A And Not B) OR (Not A Or B) *)
local
fun do_xor (alpha,beta) = Or( And( alpha, Not(beta) ), Or(Not(alpha), beta))
in
fun xor (alpha,beta) = do_xor(alpha,beta);
end;
Test:
val result = xor(Atom "a",Atom "b");
Output:
val result = Or (And (Atom #,Not #),Or (Not #,Atom #)) : prop
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…