Difference between revisions of "Not"
Jump to navigation
Jump to search
(removed {{stub}} tag) |
|||
Line 45: | Line 45: | ||
[[Category:Language]] | [[Category:Language]] | ||
[[Category:Keywords]] | [[Category:Keywords]] | ||
− | |||
− |
Latest revision as of 22:21, 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 |