Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pythonic use of logic

Name: Anonymous 2013-06-27 11:43

I have noticed a disturbing trend in the Python community. The basic rule of Python is that there should be only one way to do a thing, and there are several logical operators in use. The proper way to use logic in Python is to only use one operator. To replace them all, we should use the NAND operator ("|").

For instance, consider the statement W↔(X∧(Y∨¬Z)). It is an ugly mess! It uses four different operators when only one should suffice.

This can obviously be reduced to only three operators: (¬W∨(¬(X∧Y)∧¬(X∧¬Z)))∧(((X∧Y)∧(X∧¬Z))∨W)

But this is not nearly far enough. By using the simple rules (A∨B) = (A|A)|(B|B), (A∧B)=(A|B)|(A|B), and ¬A=(A|A) (which should be self-evident, use a truth table to verify), we can reduce this entire expression to a beautiful (((((W|W)|(W|W))|((((X|Y)|((X|(Z|Z))|(X|(Z|Z))))|((X|Y)|((X|(Z|Z))|(X|(Z|Z)))))|(((X|Y)|((X|(Z|Z))|(X|(Z|Z))))|((X|Y)|((X|(Z|Z))|(X|(Z|Z)))))))|((W|W)|(((((X|Y)|(X|Y))|(X|(Z|Z)))|(((X|Y)|(X|Y))|(X|(Z|Z))))|((((X|Y)|(X|Y))|(X|(Z|Z)))|(((X|Y)|(X|Y))|(X|(Z|Z)))))))|((((W|W)|(W|W))|((((X|Y)|((X|(Z|Z))|(X|(Z|Z))))|((X|Y)|((X|(Z|Z))|(X|(Z|Z)))))|(((X|Y)|((X|(Z|Z))|(X|(Z|Z))))|((X|Y)|((X|(Z|Z))|(X|(Z|Z)))))))|((W|W)|(((((X|Y)|(X|Y))|(X|(Z|Z)))|(((X|Y)|(X|Y))|(X|(Z|Z))))|((((X|Y)|(X|Y))|(X|(Z|Z)))|(((X|Y)|(X|Y))|(X|(Z|Z)))))))). This is much more in line with the spirit of python than using multiple things when a single, simple operator will suffice.

Name: Anonymous 2013-06-27 12:51

I had a frightening nightmare last night. Programmers started massively using languages which could not even get scoping right while others started building half-assed systems over JavaScript and HTML to badly emulate the capabilities of full-assed systems.
I fear it's actually happening.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List