in reply to Re^3: An infix fix
in thread An infix fix
As AND and OR, I think they should behave as the ops: AND returns the first false value, or the last true value if no false values are encountered; OR returns the first true value, or the last false value if no true values are encountered.I'd be curious to learn how the languages that have multi-arg AND and OR resolve this question. Of the languages I'm familiar with only Scheme fits this description, and, at least in the Scheme implementations I have on my machine (PLT Scheme/mzscheme and MIT Scheme), (and) is true and (or) is false; e.g. (for MIT Scheme):
The way I understand these generalized versions of these functions is that AND is false if any of its arguments is false, true otherwise; OR is true if any of its arguments is true, false otherwise. In this formulation, the case of no arguments is not problematic.1 ]=> (and) ;Value: #t 1 ]=> (and 3) ;Value: 3 1 ]=> (and 0) ;Value: 0 1 ]=> (or) ;Value: () 1 ]=> (or 3) ;Value: 3 1 ]=> (or 0) ;Value: 0
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: An infix fix
by Roy Johnson (Monsignor) on Mar 23, 2005 at 00:13 UTC |