Vocabulary/minusdot
>> << Down to: Dyad Back to: Vocabulary Thru to: Dictionary
-. y Not
Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?
Equivalent to 1 - y .
- for Boolean y (0 or 1) -- (-.y) is the Boolean function Not.
- for y as a probability (in the closed interval [0,1]) -- (-.y) is the complementary probability.
-. 0 1 NB. Boolean "Not" 1 0 -. 0.25 0.3333333 0.8 NB. Complements of the probabilities ("1-p" versus "p") 0.75 0.6666667 0.2
Common Uses
-.'encephalogram' e. 'aeiouAEIOU' NB. Which characters are not vowels? 0 1 1 0 1 1 0 1 0 1 1 0 1 str#~-.str e. 'aeiouAEIOU' [ str=. 'encephalogram' NB. Show only non-vowels ncphlgrm
This latter example is more elegantly accomplished using the dyadic form - see below.
2. Reverse the meaning of the trigger of an if.-statement
if. aa -.@-: bb do. ... NB. If "aa" is not equivalent to "bb" ...
Get in the habit of writing aa -.@-: bb rather than -. aa -: bb - it's faster.
3. Calculate the probability of event not happening, given the probability of it happening
%6 NB. Probability of six turning up on roll of fair 6-sided die 0.16666667 -.%6 NB. Probability of six not turning up on roll of same... 0.83333333 (-.%6)^4 NB. Probability of no sixes turning up on roll of 4 dice 0.48225309 -.(-.%6)^4 NB. Probability of at least one six turning up on roll of 4 dice 0.51774691
More Info
Related Primitives
Or (x +. y), Not-Or (x +: y), LCM (And) (x *. y), Not-And (x *: y), Boolean Functions (m b.)
Use These Combinations
Combinations using -. 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
x -. y Less
Rank Infinity -- operates on x and y as a whole, by items of x -- WHY IS THIS IMPORTANT?
When x and y are lists, x -. y is all the atoms of x that are not in y, preserving the original order in x. (A-.B) has the following Venn diagram
Common Uses
1. Remove all vowels from a string
'encephalogram' -. 'aeiouAEIOU' ncphlgrm
2. Use ([ -. -.) for the intersection of 2 lists
intersection=: [ -. -. 'encephalogram' intersection 'aeiouAEIOU' eeaoa
In the implementation, x ([ -. -.) y actually performs the function of x ([ -.!.0 -.) y.
3. Read a text file but exclude all CR (carriage-return characters)
fl=. (fread 'file.txt') -. CR fl=. CR-.~fread 'file.txt' NB. alternative form
More Information
1. x -. y uses tolerant comparison on numeric values. Use -.!.0 to force exact comparison. For intersection, use ([ -. -.!.n) to change the comparison tolerance
2. x -. y and x ([ -. -.) y are members of the i.-family.
3. If x is an atom then it is turned into a 1-element list before being processed. The result is always an array.
4. The internal rank of x -. y uses items whose rank is the rank of items of x. Calling the rank of an item of x rix, any item of x that matches an rix-cell of y is deleted.
(i. 9) -. 2 2 $ 1 3 5 6 NB. Items of x are atoms 0 2 4 7 8 (i. 3 4) -. 0 1 2 3 NB. Items of x are lists 4 5 6 7 8 9 10 11
5. If x and y are of different types, or if their items couldn't possibly match because of differing shapes, no error is signaled: each search simply fails to match, and no items are removed.
Use These Combinations
Combinations using x -. y that have exceptionally good performance include:
What it does Type;
Precisions;
RanksSyntax Variants;
Restrictions
Benefits;
Bug Warnings
Remove items of m from y -.&m y -.!.0 for exact comparison Bug warning: removes items of m from y, rather than removing items of y that match cells of m. This may lead to error if it attempts to delete part of an item of y.