# Vocabulary/tildeco

>>
<< ` `
Down to: Dyad ` `
Back to: Vocabulary
Thru to: Dictionary

`~: y`Nub Sieve

Rank Infinity *-- operates on x and y as a whole, by items of y --*
WHY IS THIS IMPORTANT?

A Boolean vector with one value per item of `y` .
Which is `1` if the item does not match any previous item.

Therefore, `1`s in the result indicate the positions of the unique items of `y`.

z=: 'abracadabra' ~.z NB. Nub z - the unique values abrcd ~:z NB. Nub Sieve z 1 1 1 0 1 0 1 0 0 0 0 (~:z) # z NB. another way to get the unique values abrcd

### Common Uses

1. Wherever data is held in 2 parallel lists, Nub Sieve (`~:`)
yields a vector capable of pruning the second list
to match the Nub (`~.`) of the first.

NAME=: 'Joe' ; 'Bob' ; 'Jim' ; 'Mary' ; 'Jim' AGE=: 25 60 32 21 33 ] z=. ~: NAME NB. "sieve" to apply to AGE 1 1 1 1 0 ] NAME=: ~. NAME +---+---+---+----+ |Joe|Bob|Jim|Mary| +---+---+---+----+ ] AGE=: z # AGE 25 60 32 21

### Related Primitives

Nub (`~. y`)

### Details

1. `~: y` is a member of the i. family.
1. `~: y` uses tolerant comparison. Use `~:!.0 y` for intolerant comparison. Because of tolerant comparison, the number of `1`s in `~: y` may depend on the order of the items of `y`.
1. `~. y` is equivalent to `(~: y) # y`.
1. The result of `~: y` is always a list.

`x ~: y`Not-Equal

Rank 0 0 *-- operates on individual atoms of x and y, producing a result of the same shape --*
WHY IS THIS IMPORTANT?

The Boolean result of comparing two items, or lists of items, atom by atom.

Use NotMatch (`x -.@-: y`) to see if two **entire nouns** are different.

]z=: i.5 0 1 2 3 4 3 ~: z 1 1 1 0 1 z ~: z 0 0 0 0 0 z ~: |.z 1 1 0 1 1

Not-Equal (`~:`) works between boxed items too:

z=: 'alpha' ; 'bravo' ; 'charlie' z ~: |.z 1 0 1 z ~: <'bravo' 1 0 1

To avoid `x~:y` giving `length error`, the Shape Of (`$`) `x` and `y`
must follow the rules for Plus (`+`).

### Common Uses

1. To construct criteria for conditional expressions in verb definitions

if. '.' ~: y do. return. end. NB. instead of: if. -. '.' = y do. return. end.

### Related Primitives

Equal (`x = y`),
Larger Than (`x > y`),
Larger Or Equal (`x >: y`),
Less Than (`x < y`),
Less Or Equal (`x <: y`),
Match (`x -: y`)

### More Information

1. See the rules for equality for a discussion of tolerant comparison and nonnumeric arguments.

### Performance Note

Comparisons are fastest when the precisions are identical. If an atom is compared against an array, it helps to choose the right precision for the atom.

0. ~: %: i. 10 NB. float list: faster than 0 ~: 00 ~: i. 10 NB. integer list: faster than 0 ~:

### Use These Combinations

Combinations using `x ~: y` that have exceptionally good performance include those shown in Searching and Matching Items: Fast List Operations (FLOs), as well as the following:

**What it does****Type;**

**Precisions;**

Ranks**Syntax****Variants;**

**Restrictions****Benefits;**

**Bug Warnings**Boolean reductions on infixes Boolean `x +./\ y``x`positive

`*. = ~:`in place of +.**much**faster than alternativesMean on infixes integer and floating-point `x (+/%#)\ y``x`positive

`*. = ~:`in place of`+`**much**faster than alternativesBoolean reductions on partitions Boolean `x +//. y``= <. >. +. * *. ~:`in place of`+`avoids building argument cells Polynomial Multiplication (Boolean) Boolean `x ~://.@(*./) y`

`x ~://.@(+./) y`

`x +//.@(*./) y`

`x +//.@(+./) y`avoids building argument cells Boolean reductions along diagonals Boolean `+.//. y``*. = ~: < <: > >:`in place of`+.`avoids building argument cells