Infix Operators
Logo defines a number of infix operators, which are commands that have a left and a right input instead of having all inputs following the command name. A typical example is the “+” operator as in “3 + 4”.
=
Also: ==
Tests its inputs for equality; two inputs.
Syntax
object = object
Description
The equality operator compares two objects, which can also be lists. If they are equal, the output is TRUE; otherwise it is FALSE. This operator is used only between two inputs, not as a prefix command. The prefix command version is .EQ
The value of the :EPSILON variable determines how the equality operator compares two numbers. See :EPSILON for details.
Examples
4 = 5 Result: FALSE
>=
Tests if its left input is greater than or equal to its right input; two inputs.
Syntax
word >= word
Description
The Greater Than or Equal operator compares two words. If the left word is greater than or equal to the right word, the output is TRUE; otherwise, it is FALSE. This operator is used only between two words, not as a prefix command. The prefix command version is .GE.
Examples
4 >= 5 Result: FALSE
>
Tests if its left input is greater than its right input; two inputs.
Syntax
word > word
Description
The Greater Than operator compares two words. If the left word is greater than the right word, the output is TRUE; otherwise it is FALSE. This operator is used only between two words, not as a prefix command. The prefix command version is .GT.
Examples
5 > 5 Result: FALSE
<=
Tests if its left input is less than or equal to its right input; two inputs.
Syntax
word <= word
Description
The Less Than or Equal operator compares two words. If the left word is less than or equal to the right word, the output is TRUE; otherwise it is FALSE. This operator is used only between two words, not as a prefix command. The prefix command version is .LE.
Examples
4 <= 5 Result: TRUE
<
Tests if its left input is less than its right input; two inputs.
Syntax
word < word
Description
The Less Than operator compares two words. If the left word is less than the right word, the output is TRUE; otherwise it is FALSE. This operator is used only between two words, not as a prefix command. The prefix command version is .LT.
Examples
4 < 5 Result: TRUE
!=
Also: <>
Tests its inputs for inequality; two inputs.
Syntax
object != object
Description
The inequality operator reports TRUE if its two inputs are not equal; otherwise it reports FALSE. Its inputs may be numbers, words, or lists. This operator is used only between two inputs, not as a prefix command. The prefix command version is .NE.
The value of the :EPSILON variable determines how the inequality operator compares two numbers. See :EPSILON for details.
Examples
6 != 6 Result: FALSE 6 != 66 Result: TRUE “AZURE <> “AZURE Result: FALSE [SPRING GREEN] != [SPRING GREEN] Result: FALSE “AZURE != [AZURE] Result: TRUE
- {#-}
Outputs the difference of two or more numbers; two inputs.
Syntax
number1 - number2
Description
The Difference operator reports the result of subtracting its right input from its left input. This operator is used only between two numbers, not as a prefix command. The prefix command version is DIFFERENCE, which can have more than two inputs.
Examples
6 - 3 Result: 3
^
Raises a number to the power of another number; two inputs.
Syntax
number ^ number
Description
The Power operator raises the left number to the power of the right number. This operator is used only between two numbers, not as a prefix command. Its prefix command version is POWER. See also EXPN.
Examples
2 ^ 3 Result: 8
*
Calculates the product of its inputs; two inputs.
Syntax
number * number
Description
The Multiply operator multiplies its inputs and reports the result. This operator is used only between two numbers, not as a prefix command. The prefix command version is PRODUCT, which also accepts more than two inputs.
Examples
2 * 3 Result: 6 4 * -1.2 Result: -4.8
/
Reports the quotient of its inputs; two inputs.
Syntax
number / number
Description
The Divide operator reports the result of dividing the left input by the right input. This operator is used only between two numbers, not as a prefix command. The prefix command version is QUOTIENT. See also REMAINDER and MODULO.
Examples
10 / 5 Result: 2
%
Outputs the remainder of two numbers; two inputs.
Syntax
dividend % divisor
Description
The Remainder oerator reports the number that is the remainder of dividing the left input by the right.
It reports the result of (dividend - (divisor * int(dividend /divisor))). The result is the same as for MODULO if the signs of both operands are the same, but are different from MODULO when the signs are different. The prefix command version is REMAINDER.
Until Logo version 4.0.4, REMAINDER was an alias for MODULO.
Examples
689 % 468 Result: 221 -123 % 4 Result: -3
+
Reports the sum of its inputs; two inputs.
Syntax
number1 + number2
Description
The Addition operator reports the result of adding its inputs. This operator is used only between two numbers, not as a prefix command. The prefix command version is SUM, which can accept more than two inputs.
Examples
3 + 6 Result: 9 3.2 + 6.4 Result: 9.6