Vocabulary/atdot

From J Wiki
Jump to: navigation, search

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

m@.n Agenda Conjunction

No rank - the result is a verb


(m@.n) creates the verb defined by the n-th atom from gerund m.

   m=: 0: ` 1: ` 2:   NB. a gerund of recognizable sample verbs
   n=: 1
   m@.n    NB. m@.n produces a verb
1:
   (m@.n) ''   NB. The verb can be executed
1

More Information

1. n may be negative to count back from the end of m.

2. If n is a list, a train of verbs is created from the selected items of m.

   m=: 0: ` 1: ` 2:
   m@.0 1
0: 1:

3. If n is boxed, each level of boxing indicates a level of parentheses in the verb train

   m@.(0;<1;<2 3)
0: (1: (2: 3:))

4. If only one atom of m is selected, the result of m@.n has the rank of the verb created from that atom. If more than one atom of m is selected, the rank of the created train is infinite.


[x] m@.v y Agenda Conjunction

Rank -- depends on the rank of v -- WHY IS THIS IMPORTANT?



[x] m@.v y executes [x] v y and uses the result to select an atom of the gerund m, which it then converts to a verb w and executes as [x] w y to produce the final result.

   NB. 3 different verbs
   soso =: verb define
smoutput 'Your score was ', ": y
)
   good =: verb define
smoutput 'Your score was ', ": y
smoutput 'Keep it up!'
)
   great =: verb define
smoutput 'Your score was ', ": y
smoutput 'That''s fantastic!'
smoutput 'Would you like to try again?'
)
   NB. Choose them according to score: 7 or less, 8-9, 10
   rate =: soso`good`great@.(7 9&I.)
   rate 4
Your score was 4
   rate 10
Your score was 10
That's fantastic!
Would you like to try again?

Common Uses

1. To get the effect of an if. statement, but with the ability to make the decision for each cell of the arguments. Give v the appropriate rank.

   (+&3)`(2&*)@.(2&|"0) 1 2 3 4   NB. Add 3 if even, multiply by 2 if odd - checking each atom separately
2 5 6 7

2. To execute different verbs for zero/positive/negative.

   ('nil'"_)`(":)`('neg ' , ":@|)@.* _5 0 5
neg 5
nil
5

Related Primitives

Power ([x] u^:v y)


More Information

1. The result of executing [x] v y must be a numeric atom.

2. Negative selections count back from the end of m.


Use These Combinations

Combinations using [x] u@.v y that have exceptionally good performance include:

What it does Type;

Precisions;
Ranks

Syntax Variants;

Restrictions

Benefits;

Bug Warnings

Fast agenda f0...fn@.v"0 y All f's must be atomic.

If v has rank 0 then "0 can be omitted