F#:

let f = function
    | 0 , 0 , 0 -> 0
    | 0 , 1 , 1 -> 0
    | 1 , 0 , 1 -> 0
    | 1 , 1 , 0 -> 0
    | _         -> 1

for a in 0..1 do
    for b in 0..1 do
        for c in 0..1 do
            printfn "%i xor %i xor %i = %i" a b c (f (a, b, c))

Output:

0 xor 0 xor 0 = 0
0 xor 0 xor 1 = 1
0 xor 1 xor 0 = 1
0 xor 1 xor 1 = 0
1 xor 0 xor 0 = 1
1 xor 0 xor 1 = 0
1 xor 1 xor 0 = 0
1 xor 1 xor 1 = 1

This man again took advantage of the fact that in D there is no such operation -> (analog switch).

Reply via email to