J'essaie de créer une formule simple avec un opérateur NAND dans un script. Existe-t-il un moyen rapide de le faire ou dois-je enchaîner un ensemble d'opérateurs NOT et AND pour les combiner en un seul?
JMP a et () et tout () fonctions qui sont à peu près équivalentes, et ou () et n'importe quel () fonctions qui sont à peu près équivalentes. l'écriture et(a,b,c) est le même que un & b & c . Il y a aussi ne pas() fonction identique à ! .
// definitions from wikipedia...
// NAND: a Boolean operator which gives the value zero if and only if
// all the operands have a value of one, and otherwise has a value of
// one (equivalent to NOT AND).
Show( !And( 1, 1, 1, 1, 0, 1, 1, 1 ) ); // 1
Show( Not( And( 1, 1, 1, 1, 1, 1, 1, 1 ) ) ); // 0
Show( !(1 & 1 & 1) ); // 0
// ALL() and AND() are similar, as are ANY() and OR()
Show( All( [1 1 1] ) ); // 1
Show( All( [1 0 1] ) ); // 0
Show( Any( [0 1 0] ) ); // 1
Show( Any( [0 0 0] ) ); // 0
// XOR: XOR gate (sometimes EOR, or EXOR and pronounced as
// Exclusive OR) is a digital logic gate that gives a true
// (1 or HIGH) output when the number of true inputs is odd.
//
// this one needs to promise only 1s and 0s for inputs
// because it is adding up the 1s to count them.
Show( Mod( Sum( 0, 0, 0, 0, 0, 0 ), 2 ) ); // 0
Show( Mod( Sum( 1, 1, 1, 1, 1, 1 ), 2 ) ); // 0
Show( Mod( Sum( 1, 1, 1, 0, 1, 1 ), 2 ) ); // 1
Show( Mod( Sum( 1, 1, 1, 1, 1, 1, 1 ), 2 ) ); // 1
Show( Mod( Sum( 1, 1, 1 ), 2 ) ); // 1
Show( Mod( Sum( 1, 0, 1 ), 2 ) ); // 0
Show( Mod( Sum( 0, 0 ), 2 ) ); // 0
Show( Mod( Sum( 0, 1 ), 2 ) ); // 1
Show( Mod( Sum( 1, 0 ), 2 ) ); // 1
Show( Mod( Sum( 1, 1 ), 2 ) ); // 0
Je viens de réaliser que c'était une question stupide et j'ai mis un not() autour de ma déclaration et.