# Vocabulary/idot

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

`i. y`Integers

Rank 1 *-- operates on lists of y, producing a result of variable shape for each one --*
WHY IS THIS IMPORTANT?

Returns an ascending (or descending) sequence of integers, wrapped to the shape specified by (`|y`).

i. 6 0 1 2 3 4 5 i. 2 3 0 1 2 3 4 5 i. 6 1 0 1 2 3 4 5

If an atom of `y` is negated, this specifies reversal along that dimension.

i. _6 5 4 3 2 1 0 i. 2 _3 2 1 0 5 4 3 i. _2 3 3 4 5 0 1 2 i. _2 _3 5 4 3 2 1 0

If `y` is all-positive, then `y` is the shape of the table (`i.y`).

That is, if `shape` is any given positive integer list, then (`i.shape`) is the same as: `shape $ i. (*/shape)`

shape=: 2 3 i.shape 0 1 2 3 4 5 shape $ i. (*/shape) 0 1 2 3 4 5

### Common uses

1. Make a sample numeric matrix for miscellaneous test purposes

] z=: i. 3 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 +/ z 15 18 21 24 27 +/"1 z 10 35 60

2. Generate the identity permutation

e.g. see the samples in Anagram Index (`A.`)

N=: 4 ] i=: i.N NB. the identity permutation on N points 0 1 2 3

3. Make a "self-indexing" numeric matrix for investigating the behavior of a given J primitive,
e.g. Transpose (`|:`).

"self-indexing" here means that each atom represents its own array index

ii=: ] {. [: i. 10 #~ # NB. utility verb for generating a test matrix ] z=: ii 2 3 4 0 1 2 3 10 11 12 13 20 21 22 23 100 101 102 103 110 111 112 113 120 121 122 123

### Use These Combinations

Combinations using `i. y` that have exceptionally good performance are shown in Miscellaneous Functions.

`x i. y`Index Of

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

Finds the *first occurrence* of `y` in `x`

'abracadabra' i. 'a' 0 'abracadabra' i. 'acd' NB. several search terms at once 0 4 6 7 < 2^i.5 0 0 0 1 1 NB. 1, 2 and 4 are smaller than 7 (7 < 2^i.5) i. 1 3 NB. inequality satisfied starting with list element no 3 7 (< i. 1:) 2^i.5 3

If list `x` doesn't contain `y`, then (`i.`) returns (`#x`)

If you subsequently use this value to index `x` then J signals ` index error`

'abcdef' i. 'k' 6 6 { 'abcdef' |index error

Use (`i.`) with a table `x` (i.e. a list of lists) to find the first row of `x` that matches `y`

This is a special case of internal rank

] x=: > 'alpha' ; 'bravo' ; 'charlie' alpha bravo charlie x i. 'charlie' 2

`y` must match the *entire row* of `x` (including any trailing fill letters) for (`i.`) to find it.
Otherwise (`i.`) returns (`#x`) (signifying "not found"), concealing your error.

So be sure to get the search term `y` right!

#x 3 x i. 'bravo' NB. i.e. not found 3 x i. 'bravo ' NB. y needs to be the full width of x 1

### Related Primitives

Index Of Last (`x i: y`)

### More Information

1. `x i. y` is a member of the i.-family.

2. The internal rank of `x i. y` uses items whose rank is the rank of items of `x`.

3. If *rix* is the rank of an item of `x`, the shape of the result is ` (-rix)}.$y`

4. If `x` and `y` are of different classes, or if their items couldn't possibly match because of differing shapes,
no error is signaled: each search simply fails to match.

5. To find *all occurrences* of `y` in `x`,
not just the first,
use Equal (`=`) or Match (`-:`) ,
together with Indices (`I.`) to convert the resulting Boolean list into indices.

'abracadabra' = 'a' 1 0 0 1 0 1 0 1 0 0 1 I. 'abracadabra' = 'a' 0 3 5 7 10 'abracadabra' I.@:= 'a' 0 3 5 7 10

### Use These Combinations

Combinations using `x i. y` that have exceptionally good performance include:

**What It Does****Type;**

**Precisions;**

Ranks**Syntax****Primitives permitted in place of**`f`**Variants;**

**Restrictions****Benefits;**

**Bug Warnings**Find first place where `x f y`is true*Permitted:*Boolean, integer, floating point, byte, symbol (**not**unicode).

`x`and`y`need not be the same precision.`x (f i. 1:) y``x i.&1@:f y``= ~: < <: > >: e. E.`*Permitted:*`(f!.0)`*(parentheses obligatory!)*to force exact comparison.

J recognizes FLO**only if**`f`returns an atom or list.Avoids computing entire `x f y`

**Bug warning:**if`f`is`e.`it does (`,@e.`) rather than`e.`regardless of ranks of argumentsFind first place where `x f y`is false`x (f i. 0:) y``x i.&0@:f y``= ~: < <: > >: e.`

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

**Precisions;**

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

**Restrictions****Benefits;**

**Bug Warnings**Find first/last match `m&i. y``i:`in place of`i.`for last match

`!.0`for exact comparisonFind index of first/last cell of `y`that does/does not match an`m`-item`(e. i. 1:)&m y``i:`in place of`i.`for last cell

`0:`for mismatch**Bug warning:**it does`(,@e.)`rather than`e.`Translate characters from `q`to`p`byte `(p {~ q i. ]) y`also `((q i.]) { p"_) y`and`(q&i. { p"_) y`Find index of first/last occurrence of largest/smallest value integer or floating-point list `(i. <./) y`

`(i. >./) y`or `i:`it actually does `(i. >.!.0/)`etc.; is faster than`0 ({ /:~) y`Bitwise operations on bytes byte `u&.(a.&i.) y``(u y) -: u"0 y`avoids conversion to integer `(m b.)/&.(a.&i.) y`

`x (m b.)&.(a.&i.) y``16 ≤ m ≤ 31`