# Equal to

 =

Equal to (=) is a comparison function which tests whether argument elements are tolerantly equal to each other: it returns 1 if the elements being compared match and 0 if they do not. It is the negation of Not Equal to (≠).

APL's = differs from the usage of $=$ in traditional mathematical notation by having an implied Iverson bracket. Thus, i=j is APL is equivalent to $[i=j]$ or $\delta _{ij}$ (Kronecker delta) in mathematics.

## Examples

Equal to compares arrays one element at a time, returning 1 when elements match and 0 when they do not.

      3 2 1 = 1 2 3
0 1 0
'321' = '123'
0 1 0
3j2 2j2 1j2 = 2j2
0 1 0


It is subject to comparison tolerance: floating-point numbers which are very close together are considered equal, even though they are slightly different:

      ⎕CT
1E¯14
x ← 1 + (⎕CT×0.6)×¯2 ¯1 0 1 2     ⍝ Numbers close to 1
1 - x                             ⍝ Nonzero difference
1.199040867E¯14 5.995204333E¯15 0 ¯5.995204333E¯15 ¯1.199040867E¯14
1 = x                             ⍝ Close but different values are equal
0 1 1 1 0
1 {⎕CT←0⋄⍺=⍵} x                   ⍝ Overriding ⎕CT within a dfn
0 0 1 0 0


In a nested APL, Equal to is pervasive, and compares all simple scalars found in a nested array.

      ⎕←n ← ((2 1)0)(1 0 3)(2 2⍴4 0)
┌───────┬─────┬───┐
│┌───┬─┐│1 0 3│4 0│
││2 1│0││     │4 0│
│└───┴─┘│     │   │
└───────┴─────┴───┘
0 = n
┌───────┬─────┬───┐
│┌───┬─┐│0 1 0│0 1│
││0 0│1││     │0 1│
│└───┴─┘│     │   │
└───────┴─────┴───┘


In a flat array language such as J, it instead compares Boxes directly, since they are the elements of a boxed array.

   (<'string') = 'which';'is';'string';'?'
0 0 1 0


## Boolean function

Main article: Boolean function

When the arguments to Equal to are Boolean, it is the Logical biconditional function, or the negation of the xor function (which is Not Equal to restricted to Boolean arguments):

= 0 1
0 1 0
1 0 1

In the context of logic, it can be read as if and only if. This function is also known as xnor or the Kronecker delta.

Reduction with = is the same as reduction with xor (≠), but inverted if the number of reduced elements is even. The left and right identity element for Boolean = is 1.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7914752,"math_prob":0.9901437,"size":2042,"snap":"2021-31-2021-39","text_gpt3_token_len":784,"char_repetition_ratio":0.11923455,"word_repetition_ratio":0.0,"special_character_ratio":0.32272282,"punctuation_ratio":0.08695652,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98894626,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,null,null,10,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-08-01T22:22:08Z\",\"WARC-Record-ID\":\"<urn:uuid:1564ec3d-a625-4ed4-b8fa-02f9e1ae68e4>\",\"Content-Length\":\"39520\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:02206451-1f5d-4525-86f8-2f725b3db8d3>\",\"WARC-Concurrent-To\":\"<urn:uuid:fad8a53b-5743-4571-b912-2c3bd5e5b109>\",\"WARC-IP-Address\":\"89.107.61.216\",\"WARC-Target-URI\":\"https://aplwiki.com/wiki/Equal_to\",\"WARC-Payload-Digest\":\"sha1:5D2T4D2DG3AWDDAYFCFJFKSCAWAMB5Y2\",\"WARC-Block-Digest\":\"sha1:K32BL76CQMZXHBUWBBWGR44E5KOWFCHV\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-31/CC-MAIN-2021-31_segments_1627046154277.15_warc_CC-MAIN-20210801221329-20210802011329-00086.warc.gz\"}"}