From J Wiki
Jump to: navigation, search

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

i: y Steps

Rank 0 -- operates on individual atoms of y, producing a result that may require fill -- WHY IS THIS IMPORTANT?

Like Integers (i.), except that the sequence ranges from (-y) thru (+y).

   i: 4
_4 _3 _2 _1 0 1 2 3 4

   i: _4
4 3 2 1 0 _1 _2 _3 _4

More Information

1. i: y operates on each atom of y independently, and produces a list for each one.

2. If y is a complex number a+bi (ajb or a j. b in J notation), its imaginary part b gives the number of steps between -a and a i.e. the result will contain b+1 atoms. In this case a may be any number.

3. If y has no imaginary part or the imaginary part is 0, the size of each step is 1. In this case y must be an even multiple of 0.5 (using tolerant comparison).

x i: y Index Of Last

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

Like Index Of (i.), except that it finds the last occurrence not the first.

   'abracadabra' i: 'a'

   'abracadabra' i: 'abc'   NB. several search terms at once
10 8 4

If the item is not found, the result is still #x, same as for x i. y.

Related Primitives

Index Of (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 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.

Use These Combinations

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

What It Does Type;


Syntax Primitives permitted in place of f Variants;



Bug Warnings

Find last 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. 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 arguments

Find last place where  x f y is false x (f i: 0:) y x i:&0@:f y = ~: < <: > >: e.
What it does Type;


Syntax Variants;



Bug Warnings

Find first/last match m&i. y i: in place of i. for last match

!.0 for exact comparison

Find 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.
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