No more logical XOR

Merlyn Leroy <Brian Westley> brian at digi-g.UUCP
Wed Nov 28 02:55:04 AEST 1984


<find the bug in this picture>

OK, since hardly anybody seemed to like my idea of logical XOR (^^),
and wanted me to use !a!=!b instead of a^^b, I have another proposal;
replace all operators with NAND ops!  This new operator ($ for bitwise,
$$ for logical) can replace nearly everything, vis;

a & b  -->  (a $ b) $ (a $ b)
a | b  -->  (a $ a) $ (b $ b)
a ^ b  -->  ((a $ a) $ b) $ (a $ (b $ b))
~a     -->  (a $ a)
a && b -->  (a $$ b) $$ (a $$ b)
a || b -->  (a $$ a) $$ (b $$ b)
a ^^ b -->  ((a $$ a) $$ b) $$ (a $$ (b $$ b))	[I never give up]
!a     -->  (a $$ a)
a == b -->  (((a $ a) $ b) $ (a $ (b $ b))) $$ (((a $ a) $ b) $ (a $ (b $ b)))
a != b -->  ((a $ b) $ ((a $ a) $ (b $ b))) $$ ((a $ b) $ ((a $ a) $ (b $ b)))
e?a:b  -->  (((e $$ e)-1) $ a) $ ((((e $$ e) $$ (e $$ e))-1) $ b)

(the last three operators don't work with floats, but REAL programmers don't
need floats)

Now we can get rid of those extra operators, like & | ^ ~ && || ! == != and ?:
and replace them with one (well, two) simple operators.  Ideally, this would be
implemented on a computer built entirely of NOR gates.

Notice how this simplifies expressions:
if (!a || (b == c))
	becomes:
if (((a $$ a) $$ (a $$ a)) $$
    ((((b $ b) $ c) $ (b $ (c $ c))) $$ (((b $ b) $ c) $ (b $ (c $ c))) $$
     (((b $ b) $ c) $ (b $ (c $ c))) $$ (((b $ b) $ c) $ (b $ (c $ c)))))

Next week:  Replacing +-*/%++ with --

							Merlyn Leroy

P.S.  The ":-)" operator can be replaced by ((:$-) $$ (: $ :) $ (-$$-))



More information about the Comp.lang.c mailing list