diff --git a/mathics/builtin/comparison.py b/mathics/builtin/comparison.py index e083bf48fb..7b225fb251 100644 --- a/mathics/builtin/comparison.py +++ b/mathics/builtin/comparison.py @@ -652,10 +652,9 @@ def _op(x): class Unequal(_EqualityOperator, SympyComparison): - """ + u"""
-
'Unequal[$x$, $y$]' -
'$x$ != $y$' +
'Unequal[$x$, $y$]' or $x$ != $y$ or $x$ \u2260 $y$
is 'False' if $x$ and $y$ are known to be equal, or 'True' if $x$ and $y$ are known to be unequal. Commutative properties apply so if $x$ != $y$ then @@ -667,15 +666,19 @@ class Unequal(_EqualityOperator, SympyComparison): >> 1 != 1. = False + Comparsion can be chained: + >> 1 != 2 != 3 + = True + + >> 1 != 2 != x + = 1 != 2 != x + Strings are allowed: Unequal["11", "11"] = False - Equal["121", "11"] - = True - Comparision to mismatched types is True: - Equal[11, "11"] + Unequal[11, "11"] = True Lists are compared based on their elements: @@ -723,16 +726,19 @@ def _op(x): class Less(_ComparisonOperator, SympyComparison): """
-
'Less[$x$, $y$]' -
'$x$ < $y$' -
yields 'True' if $x$ is known to be less than $y$. -
'$lhs$ < $rhs$' -
represents the inequality $lhs$ < $rhs$. +
'Less[$x$, $y$]' or $x$ < $y$ +
yields 'True' if $x$ is known to be less than $y$.
- #> {Less[], Less[x], Less[1]} - = {True, True, True} + LessEqual operator can be chained: + >> LessEqual[1, 3, 3, 2] + = False + + >> 1 < 3 < 3 + = False + >> 1 < 3 < x < 2 + = 1 < 3 < x < 2 """ operator = "<" @@ -740,32 +746,37 @@ class Less(_ComparisonOperator, SympyComparison): class LessEqual(_ComparisonOperator, SympyComparison): - """ -
-
'LessEqual[$x$, $y$]' -
'$x$ <= $y$' -
yields 'True' if $x$ is known to be less than or equal to $y$. -
'$lhs$ <= $rhs$' -
represents the inequality $lhs$ $rhs$. -
+ u""" +
+
'LessEqual[$x$, $y$, ...]' or $x$ <= $y$ or $x$ \u2264 $y$ +
yields 'True' if $x$ is known to be less than or equal to $y$. +
+ + LessEqual operator can be chained: + >> LessEqual[1, 3, 3, 2] + = False + + >> 1 <= 3 <= 3 + = True + """ operator = "<=" - sympy_name = "LessThan" + sympy_name = "LessThan" # in contrast to StrictLessThan class Greater(_ComparisonOperator, SympyComparison): """
-
'Greater[$x$, $y$]' -
'$x$ > $y$' -
yields 'True' if $x$ is known to be greater than $y$. -
'$lhs$ > $rhs$' -
represents the inequality $lhs$ > $rhs$. +
'Greater[$x$, $y$]' or '$x$ > $y$' +
yields 'True' if $x$ is known to be greater than $y$.
+ + Greater operator can be chained: >> a > b > c //FullForm = Greater[a, b, c] - >> Greater[3, 2, 1] + + >> 3 > 2 > 1 = True """ @@ -776,12 +787,10 @@ class Greater(_ComparisonOperator, SympyComparison): class GreaterEqual(_ComparisonOperator, SympyComparison): """
-
'GreaterEqual[$x$, $y$]' -
'$x$ >= $y$' -
yields 'True' if $x$ is known to be greater than or equal +
'GreaterEqual[$x$, $y$]' +
$x$ \u2256 $y$ or '$x$ >= $y$' +
yields 'True' if $x$ is known to be greater than or equal to $y$. -
'$lhs$ >= $rhs$' -
represents the inequality $lhs$ $rhs$.
"""