Vocabulary/squarert
>> << Down to: Dyad Back to: Vocabulary Thru to: Dictionary
] y Same
Rank Infinity -- operates on x and y as a whole -- WHY IS THIS IMPORTANT?
Returns noun y unchanged, i.e. (]y) is equivalent to y.
z=: i.6 NB. try any noun here assert z -: ]z
NOTE: Same ([ y) is equivalent to (] y).
Common uses
1. Use in the J session to both display a noun and assign it to a name with a single sentence
] z=: i:2 _2 _1 0 1 2
2. In a train of verbs, refer to the argument of the train
(2 { ]) 3 1 4 1 5 9 4
When ] is executed, it is replaced by the value of its argument, which is the argument of the train (2 { ])
Related Primitives
Same ([ y)
Use These Combinations
Combinations using ] y that have exceptionally good performance include:
What it does Type;
Precisions;
RanksSyntax Variants;
Restrictions
Benefits;
Bug Warnings
Extract substring/subarray table or list x ];.0 y or [;.0 avoids creating indexes Translate characters from q to p byte (p {~ q i. ]) y also ((q i.]) { p"_) y and (q&i. { p"_) y Reshape infixes x ]\ y [ , in place of ]
x ] y Right
Rank Infinity -- operates on x and y as a whole -- WHY IS THIS IMPORTANT?
Returns the (noun) value of y -- ignoring x
x=: 3 y=: 5 x ] y 5 assert y -: x ] y NB. try with any 2 nouns as x and y
Common uses
1. Separate two (numeric) atoms to prevent J treating them as a single noun (list)
i."0 3 4 5 |length error i."0 ] 3 4 5 NB. need to separate the 0 3 4 5 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 ;: 'i."0 3 4 5' NB. see, they were treated as one word +--+-+---------+ |i.|"|0 3 4 5| +--+-+---------+
2. Use with a conjunction or adverb where the identity verb suffices to yield the behavior required
_3 ]\ 1 0 0 0 1 0 0 0 1 1 0 0 0 1 0 0 0 1
3. In a tacit verb (monad or dyad): use ] (and [) to bring in the value(s) of argument(s) y (and x)
13 : 'x+(x-y)*y' NB. converts code string to a tacit verb [ + - * ]
4. In a dyadic tacit verb: use u@] to execute u on the y-argument of the verb
3 (< , <) 'a' NB. No good: the < are executed as dyads |domain error 3 (<@[ , <@]) 'a' NB. Execute as monads on the appropriate argument +-+-+ |3|a| +-+-+
Related Primitives
Left (x [ y)
Use These Combinations
Combinations using x ] y that have exceptionally good performance include:
What it does Type;
Precisions;
RanksSyntax Variants;
Restrictions
Benefits;
Bug Warnings
Fetch from multiple index lists (each row of x is one index list into y) x (<"1@[ { ]) y avoids boxing x Monadic power whose power depends on x x f@]^:g y
(f is any verb)
Applies f rather than x&(f@]) (very small improvement)