Pyli/Methods/Logical

From Jonathan Gardner's Tech Wiki
< Pyli‎ | Methods
Jump to: navigation, search

Logical Methods

  • (ident val): Returns val, unmodified. Opposite of not.
  • (not val): True if False, False otherwise.
  • (and a b ...): True if all of a, b, etc... are True. Employs short-circuiting and returns the last value.
  • (or a b ...): True if any of a, b, etc... are True. Employs short-circuiting and returns the first true value.
  • (nand a b ...): True if all of a, b, etc... are False. Employs short-circuiting but only returns True or False.
    • (nand a b c d) => (and (not a) (not b) (not c) (not d))
  • (nor a b ...): True if any of a, b, etc... are False. Employs short-circuiting but only returns True or False.
    • (nor a b c d) => (or (not a) (not b) (not c) (not d))
  • (xor a b) => True if a is True and b is False, or vice-versa. Returns the true value.
    • (xor False False) => False
    • (xor False 5) => 5
    • (xor 7 False) => 7
    • (xor 7 5) => False