Not Equal to: Difference between revisions

Jump to navigation Jump to search
294 bytes added ,  21:57, 28 November 2022
m
m (Text replacement - "<source" to "<syntaxhighlight")
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Built-in|Not Equal to|<nowiki>≠</nowiki>}} is a [[comparison function]] which tests whether argument elements are [[Tolerant comparison|tolerantly]] unequal. It is the [[Not|negation]] of [[Equal to]] (<syntaxhighlight lang=apl inline>=</source>). Thus it returns 0 if the [[element]]s being compared [[match]] and 1 if they do not.
{{Built-in|Not Equal to|<nowiki>≠</nowiki>}} is a [[comparison function]] which tests whether argument elements are tolerantly<ref>[[Robert Bernecky|Bernecky, Robert]]. [https://www.jsoftware.com/papers/satn23.htm "Comparison Tolerance"]. Sharp APL Technical Notes. 1977-06-10;.</ref> unequal. It is the [[Not|negation]] of [[Equal to]] (<syntaxhighlight lang=apl inline>=</syntaxhighlight>). Thus it returns 0 if the [[element]]s being compared [[match]] and 1 if they do not.
 


== Examples ==
== Examples ==
Line 7: Line 8:
       2 2.5 3 3.5 ≠ 2.5
       2 2.5 3 3.5 ≠ 2.5
1 0 1 1
1 0 1 1
</source>
</syntaxhighlight>


== Boolean function ==
== Boolean function ==
Line 13: Line 14:
When the arguments to Not Equal to are [[Boolean]], it is the [[wikipedia:exclusive or|exclusive or]] or xor function:
When the arguments to Not Equal to are [[Boolean]], it is the [[wikipedia:exclusive or|exclusive or]] or xor function:
{|class=wikitable
{|class=wikitable
!<syntaxhighlight lang=apl inline>≠</source>!!<syntaxhighlight lang=apl inline>0</source>!!<syntaxhighlight lang=apl inline>1</source>
!<syntaxhighlight lang=apl inline>≠</syntaxhighlight>!!<syntaxhighlight lang=apl inline>0</syntaxhighlight>!!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|-
|-
!<syntaxhighlight lang=apl inline>0</source>
!<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|<syntaxhighlight lang=apl inline>0</source>||<syntaxhighlight lang=apl inline>1</source>
|<syntaxhighlight lang=apl inline>0</syntaxhighlight>||<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|-
|-
!<syntaxhighlight lang=apl inline>1</source>
!<syntaxhighlight lang=apl inline>1</syntaxhighlight>
|<syntaxhighlight lang=apl inline>1</source>||<syntaxhighlight lang=apl inline>0</source>
|<syntaxhighlight lang=apl inline>1</syntaxhighlight>||<syntaxhighlight lang=apl inline>0</syntaxhighlight>
|}
|}
Xor is one of the most important [[Boolean function]]s because it is equivalent to [[addition]] of the arguments with [[modulus]] 2. Like addition, it is [[wikipedia:Commutative property|commutative]] and [[wikipedia:Associative property|associative]]. It is also equivalent to [[subtraction]] with modulus 2 because the [[Minus|negative]] of a number is the same as the original number (mod 2): the negative of an odd number is still odd, and the negative of an even number is still even.
Xor is one of the most important [[Boolean function]]s because it is equivalent to [[addition]] of the arguments with [[modulus]] 2. Like addition, it is [[wikipedia:Commutative property|commutative]] and [[wikipedia:Associative property|associative]]. It is also equivalent to [[subtraction]] with modulus 2 because the [[Minus|negative]] of a number is the same as the original number (mod 2): the negative of an odd number is still odd, and the negative of an even number is still even.


[[Reduction]] of a Boolean [[vector]] using Not Equal to yields 1 if there were an odd number of 1s in the argument and 0 otherwise. In APL, if <syntaxhighlight lang=apl inline>v</source> is a Boolean vector then <syntaxhighlight lang=apl inline>≠/v</source> {{←→}} <syntaxhighlight lang=apl inline>2|+/v</source>.
[[Reduction]] of a Boolean [[vector]] using Not Equal to yields 1 if there were an odd number of 1s in the argument and 0 otherwise. In APL, if <syntaxhighlight lang=apl inline>v</syntaxhighlight> is a Boolean vector then <syntaxhighlight lang=apl inline>≠/v</syntaxhighlight> {{←→}} <syntaxhighlight lang=apl inline>2|+/v</syntaxhighlight>.


== External links ==
== External links ==
Line 33: Line 34:
* J [http://www.jsoftware.com/help/dictionary/d222.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/tildeco#dyadic NuVoc]
* J [http://www.jsoftware.com/help/dictionary/d222.htm Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/tildeco#dyadic NuVoc]
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#comparisons BQN]
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#comparisons BQN]
== References ==
<references />


{{APL built-ins}}[[Category:Primitive functions]][[Category:Comparison functions]]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Comparison functions]]

Navigation menu