Guides/Language FAQ/MatchElements

From J Wiki
Jump to navigation Jump to search

Why do/don't these (similar items) match?

Often it seems impossible to match items that seem identical. At other times we are surprised that "different" items do match. Some examples follow.

Case sensitive

   'a' -: 'A'  NB. No surprise here
0

Rank

   1 ; ,1   NB. these look equal, but ...
+-+-+
|1|1|
+-+-+
   1 -:  ,1 NB. a scalar vs a vector
0

   1 2 3 ;  ,:1 2 3   NB. these look equal, too
+-----+-----+
|1 2 3|1 2 3|
+-----+-----+
   1 2 3 -:  ,:1 2 3  NB. a vector vs an array
0

Type

   1 ; '1'   NB. these look equal
+-+-+
|1|1|
+-+-+
   1 -: '1' NB. numeric vs literal
0

Unicode

   '∇' -: '▽'  NB. 16b2207 vs 16b25bd
0

Floating point tolerance

   1 = 1+1e_14
1
   1 = 1+1e_10
0

Contributed by Brian Schott