Next / Previous / Contents / Shipman's homepage

16. Truths._codeMatch

The logic is straightforward. T matches True, F matches False, and X matches anything.

# - - -   T r u t h s . _ c o d e M a t c h

    def _codeMatch(self, input, code):
        '''See if this input matches this T/F/X value.

          [ (input is a bool) and
            (code is in TRUTH_CODES) ->
              if code == X ->
                return True
              else if code == T ->
                if input is True -> return True
                else -> return False
              else ->
                if input is False -> return True
                else -> return False ]
        #-- 1
        if code == X:
            return True
        elif code == T:
            if input: return True
            else: return False
            if input: return False
            else: return True