0

I am trying to represent the return cases of this psuedo code function as an expression. Specifically to illustrate which return case executes when (A==X)&&(B==Y)

Enum is defined as {X, Y, Z}

Enum function(Enum A,Enum B)
    if ((A==X)||(B==X))
        return X
    else if ((A==Y)||(B==Y))
        return Y
    else
        return Z

Does anyone know how to do this properly. I was trying to use a 6 variable Kmap but my answer did not seem to be correct. The closest I have gotten is the following:

R1 is the return case X
R2 is the return case Y
R3 is the return case Z

R1: ((A==X)||(B==X))
R2: ((!R1)&&((A==Y)||(B==Y)))
    (((!((A==X)||(B==X)))&&((A==Y)||(B==Y)))
R3: (!R2)
    (!(((!((A==X)||(B==X)))&&((A==Y)||(B==Y))))

But when I go to apply the ! cases to manipulate the representation I get lost. Would it follow something similar to Boolean Logic where ORs become ANDs and == would become != ?

1 Answers1

0

It is the same logic. You are talking about De Morgan's laws. They might try to confuse you in school by teaching you three or four different ways to do the same logic problems, all using different symbols. The logic is all exactly the same. Different disciplines just have their own conventions.

Bort
  • 817
  • 6
  • 22