Difference between revisions of "Not"

From MiniScript Wiki
Jump to navigation Jump to search
(filled out details)
Line 15: Line 15:
 
|}
 
|}
  
This is consistent with MiniScript’s support for [[fuzzy logic]].  If interpreted as probability, then if <c>p</c> is the probability of an event happening, <c>not p</c> is the probability of that event ''not'' happening.
+
This is consistent with MiniScript’s support for [[Fuzzy Logic|fuzzy logic]].  If interpreted as probability, then if <c>p</c> is the probability of an event happening, <c>not p</c> is the probability of that event ''not'' happening.
  
 
== Non-Numeric Operands ==
 
== Non-Numeric Operands ==

Revision as of 22:14, 29 March 2023

not is a keyword unary operator that returns the logical negation of its operand. In its simplest usage, not true is equal to false, and not false is equal to true.

Numeric Operands

In detail, for any numeric operand x, the result of not x depends on the absolute value of x. The full truth table for not with numeric operands is shown below.

Range of abs(x) not x
abs(x) <= 0 1
0 < abs(x) < 1 1 - x
abs(x) >= 1 0

This is consistent with MiniScript’s support for fuzzy logic. If interpreted as probability, then if p is the probability of an event happening, not p is the probability of that event not happening.

Non-Numeric Operands

When used with types other than numbers, not returns 1 (true) if the given value is “empty”, and 0 (false) if the operand is “not empty”, as shown below.

Type of x Characteristic of x not x
string empty, i.e. x.len == 0 1
string non-empty, i.e. x.len > 0 0
list empty, i.e. x.len == 0 1
list non-empty, i.e. x.len > 0 0
map empty, i.e. x.len == 0 1
map non-empty, i.e. x.len > 0 0
function any 0
null (N/A) 1


This article is a stub. You can help the MiniScript Wiki by expanding it.