Unequal¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
lhs != rhs or Unequal[lhs, rhs] is the negation of Equal: True if lhs and rhs can be decided unequal, False if they can be decided equal, otherwise unevaluated. Per IEEE 754, an Indeterminate argument gives True.
Examples (3)¶
Every input below was run against the current Mathilda build and its output recorded.
Applications (3)¶
Implementation notes¶
builtin_unequal is the value-level (not structural) negation of Equal. For every argument pair it first checks expr_eq; on failure it tries compare_numeric to decide equality/inequality numerically. If any pair is found equal it returns False immediately. It returns True only when every pair is provably unequal ā either decided by compare_numeric or, for non-comparable values, when both sides are distinct raw data (is_raw_data). If some pair is neither equal nor provably unequal (e.g. symbolic), it returns NULL so the call stays unevaluated. Fewer than two arguments returns True.
- A pair containing
Indeterminatecounts as unequal, soIndeterminate != IndeterminateisTrue. An equal non-Indeterminatepair still decides the whole callFalse. - Like
Equal, an undecided pair of numeric constants is settled by the exact zero-test, soI != 0and2 I Pi != 0areTrue, while a free symbol stays symbolic (x != 0).
Attributes: Protected.
References¶
See also: Inequality, Equal
- Source:
src/comparisons.c - Specification:
docs/spec/builtins/comparisons.md - Tests:
tests/test_assoc_atomicity.c - Tests:
tests/test_comparisons.c - Tests:
tests/test_parse.c - Tests:
tests/test_reduce.c
Notes & additional examples¶
Notes¶
Unequal (!=) is the negation of Equal: True if the arguments are decidably unequal, False if decidably equal, otherwise it stays unevaluated.