[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

This page is part of the web mail archives of SRFI 33 from before July 7th, 2015. The new archives for SRFI 33 contain all messages, not just those from before July 7th, 2015.

*To*: srfi-33@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Subject*: NAND & NOR now n-ary; Bug in BITWISE-EQV? implementation*From*: shivers@xxxxxxxxxxxxx*Date*: Sun, 21 Jul 2002 13:14:13 -0400*Delivered-to*: srfi-33@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*Reply-to*: shivers@xxxxxxxxxxxxx

I went ahead & changed nand & nor to be n-ary, as Marc suggested. I also discovered a bug in the spec for n-ary eqv. This is true: (eqv i j) = (not (xor i j)) But it does not generalise to the n-ary case. That is, it is *NOT TRUE* that (eqv i ...) = (not (xor i ...)) This buggy n-ary definition appears in the spec and the implementation of n-ary eqv. Here is the bogus definition from the reference implementation: (define (bitwise-eqv . args) (bitwise-not (apply bitwise-xor args))) Nope. To use the not-xor definition, you must fold it across the args; you can't save the not operation until the very end. So this is correct: (define (bitwise-eqv . args) (reduce (lambda (a b) (bitwise-not (bitwise-xor a b))) -1 args)) or, sticking to the R5RS core: (define (bitwise-eqv . args) (let lp ((args args) (ans -1)) (if (pair? args) (lp (cdr args) (bitwise-not (bitwise-xor ans (car args)))) ans))) I have changed the SRFI accordingly. The new draft is at http://www.cc.gatech.edu/~shivers/srfi/srfi-33.txt and will propagate out to the standard url http://srfi.schemers.org/srfi-33/srfi-33.html in the hands of esteemed editor Solsona in the near future. If anyone knows of a simpler n-ary definition of eqv that could be simply expressed in terms of n-ary primitives like and, or and xor, I would like to see it. -Olin

**Follow-Ups**:**Re: NAND & NOR now n-ary; Bug in BITWISE-EQV? implementation***From:*Marc Feeley

**The boolean eqv function & n-ary generalisation of associative ops***From:*shivers

- Prev by Date:
**n-ary nand & nor; trivial ops; replace-bit-field** - Next by Date:
**Re: NAND & NOR now n-ary; Bug in BITWISE-EQV? implementation** - Previous by thread:
**n-ary nand & nor; trivial ops; replace-bit-field** - Next by thread:
**Re: NAND & NOR now n-ary; Bug in BITWISE-EQV? implementation** - Index(es):