Language | False | True | Short-Circuiting Logic And | Short-Circuiting Logic Or | Notes |
---|---|---|---|---|---|
LISP | NIL | T, anything but NIL (including 0) | (and) | (or) | Most elegant in my opinion. NIL is the absence of a value. Anything but NIL is a value and thus true, including 0. Zero is a value too — but many languages disagree. |
C | 0 | 1, anything but 0 | && | || | C is designed to be the portable assembly languages. Most hardware can only store values, not absence of values, so 0 is probably the best emulation of Lisp's NIL. |
Perl | undef, 0, 0.0, "" | 1, anything but false | && | || | Mix of Lisp's and C's true/false values: undef is like Lisp's NIL, although the valid number 0 and the valid empty string are considered false. |
Unix Shell | anything but 0 | 0 | && | || | Programs usually return 0 (EXIT_SUCCESS) on success, non-zero on failure. The logic operators respect this. |
Python | None, 0, "", [], {} | anything but false | and | or | Source: http://www.norvig.com/python-lisp.html |
TI Basic? | even numbers (0) | odd numbers (-1) | * | + | Not sure if this is TI-Basic. Older versions maybe? The LSB indicates the Boolean value. |
Modified Sun Mar 25 08:48:47 2007
generated Sun Mar 25 08:56:33 2007
http://jeff.tk/truefalse/