Choose Language Hide Translation Bar
Highlighted
Level I

## Is there a function for a NAND logical operator?

I'm trying to make a simple formula with a NAND operator in a script. Is there a quick way to do it or do I need to chain together a bunch of NOT and AND operators to combine into one?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Level I

## Re: Is there a function for a NAND logical operator?

I just realized this a dumb question, and put a not() around my and statement.

2 REPLIES 2
Highlighted
Level I

## Re: Is there a function for a NAND logical operator?

I just realized this a dumb question, and put a not() around my and statement.

Highlighted
Staff (Retired)

## Re: Is there a function for a NAND logical operator?

JMP has and() and all() functions that are roughly equivalent, and or() and any() functions that are roughly equivalent. writing and(a,b,c) is the same as a & b & c . There is also a not() function that is the same as ! .

``````// 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``````

Craige
Article Labels