If (implies a b ... z) is equivalent to (implies a (implies b ... z)), then it is also equivalent to (implies (and a b ...) z). In which case, the 1-ary case should be clear: just return z. In truth, it is not really necessary to have n-ary implies if you're willing to nest the (and ...) explicitly. Given that Scheme/Racket n-ary operators tend to have the "..." last, with occasional exceptions like list* and apply, restricting implies to 2 arguments might avoid cases where (implies a b c d e) is confusing to read. (implies (and a b c d) e) is clearer.
Carl Eastlund On Sun, Feb 19, 2012 at 8:16 PM, Robby Findler <ro...@eecs.northwestern.edu>wrote: > On Sun, Feb 19, 2012 at 7:10 PM, Neil Toronto <neil.toro...@gmail.com> > wrote: > > On 02/19/2012 06:05 AM, Robby Findler wrote: > >> > >> On Sun, Feb 19, 2012 at 12:30 AM, Gary Baumgartner<g...@cs.toronto.edu> > >> wrote: > >>> > >>> On a more productive note: in Racket code I define and use 'implies' a > >>> lot, > >>> often conjoined, for predicates. It's mainly of declarative value, > which > >>> is > >>> perhaps why it's uncommon in implementation despite how common it is > in > >>> specification. And for boolean expressions in general I also use > >>> 'neither'. > >>> Are these something that others [would] use and so could be added to > >>> Racket's > >>> library? > >> > >> > >> Seems to me adding implies, nand, and nor to racket/bool is a good idea. > >> > >> Let me know if you disagree (and if you disagree after I've already > >> committed, it is a simple thing to drop the commit or change it). > > > > > > I've occasionally written my own `implies', but never make it shortcut > like > > `and' and `or'. Speaking of which, would it handle more than two > arguments? > > One? Zero? What kind of associativity would be appropriate? > > The version I checked in shortcuts in an implication-appropriate way > (if the first argument is #f). I think the convention (due to > functions and currying) is pretty well established that it associates > to the right. So that's what the version I checked in does for the 3+ > argument case. I didn't see something reasonable for the 0 or 2-ary > case so it doesn't handle them. > > > Bwahaha. > > :) > > I'm still pondering those questions for xor. :) > > Robby > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users >
____________________ Racket Users list: http://lists.racket-lang.org/users