Vocabulary/ampm

From J Wiki
Jump to: navigation, search

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

m&v y u&n y Bond Conjunction

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


(m&v) makes a monad out of a dyad v by supplying the (noun) value m as the left argument of v

(m&v y) is the same as (m v y)

   triple =: 3&*
   i: 3
_3 _2 _1 0 1 2 3

   triple i: 3  NB. Same as 3 * i: 3
_9 _6 _3 0 3 6 9

Conversely...

(u&n) makes a monad out of a dyad u by supplying the (noun) value n as the right argument of u

(u&n y) is the same as (y u n)

   i:3
_3 _2 _1 0 1 2 3

   gt0=: >&0
   gt0 i:3  NB. Same as (i:3) > 0
0 0 0 0 1 1 1

Common Uses

1. Weld a noun to a verb, creating a unit that bypasses processing by other modifiers. To prefix 'Mr. ' to each boxed string:

   'Mr. '&, each 'Jones';'Smith';'Williams'
+---------+---------+------------+
|Mr. Jones|Mr. Smith|Mr. Williams|
+---------+---------+------------+

2. Create a monad out of a dyad when one is required.


x m&v y x u&n y Bond Conjunction

Rank 0 _ -- operates on atoms of x, and the entirety of y -- WHY IS THIS IMPORTANT?


The dyad form applies the monad form to y repeatedly x times...

  • Phrase:  x m&v y applies m&v to y repeatedly x times, and is equivalent to:  x (m&v @ ] ^: [)"0 _ y
  • Phrase:  x u&n y applies u&n to y repeatedly x times, and is equivalent to:  x (u&n @ ] ^: [)"0 _ y

See above for a description of the monadic form.