Vocabulary/minusco
>> << Down to: Dyad Back to: Vocabulary Thru to: Dictionary
-: y Halve
Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?
Equivalent to y % 2 (y divided by 2).
Common Uses
Has advantages in tacit definitions over (expression)%2.
More Information
Related Primitives
Double (+: y), Square (*: y), Square Root (%: y)
x -: y Match
Rank Infinity -- operates on x and y as a whole -- WHY IS THIS IMPORTANT?
Returns a boolean value, 1 if and only if x is the same as y in shape and elements. Tolerant comparison is used whenever numeric types are compared; use -:!.0 to force exact comparison.
'no' -: |. 'on' 1 'no' -: 'yes' 0
Use x -: y to compare two entire nouns for equality. If you want to test equality of individual atoms in a noun, use =.
Common Uses
1. Matching strings of varying length.
reply=: 'yes' reply = 'yes' 1 1 1 reply = 'no' |length error | reply ='no' reply -: 'yes' 1 reply -: 'no' 0
2. Comparing entire arrays for equality.
]a =. i. 2 3 0 1 2 3 4 5 ]b =. |. a NB. Reverse order of rows 3 4 5 0 1 2 a -: b 0 a -: |. b 1
3. Shape matters for matching
]a =. 9 NB. Create a noun 9 ]b =. a -. 5 NB. Remove any items that match 5. There aren't any, so no change 9 b -: a NB. Want to bet there was no change? 0 $a NB. What happened? a is an atom... $b NB. ...but b became a list 1 b -: ,a 1
Related Primitives
Equal (x = y)
More Information
1. Two nouns that match are equivalent for most purposes, the exception being empty arrays. (An empty array is one that contains no items). J primitives that accept lists as control arguments perform the same on empty arrays of any type (examples: x in x { y or x {. y). However, if an empty array must be filled, because it is a data argument or is applied to a verb of lower rank, the fill will depend on the type of the empty argument.
'' -: 0$0 NB. Empty arrays match... 1 ({. '') -: ({. 0 $ 0) NB. but are not always equivalent 0
2. Nouns that match may have different types as disclosed by 3!:0.
Use These Combinations
Combinations using x -: y that have exceptionally good performance include:
What it does Type;
Precisions;
RanksSyntax Variants;
Restrictions
Benefits;
Bug Warnings
Not-match x -.@-: y @: in place of @ Use this form for not-match. Supported as a primitive by (-.@-:)"n