From J Wiki
Jump to navigation Jump to search

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

[x] u&v y Compose Conjunction

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

Applies v to each cell of each argument, and then applies u to the result(s) of v for each cell separately

   ('Ike';'James') >&#&> ('Newton';'Bond')  NB. Is first name longer than last name?
0 1

This contrasts with u&:v which applies v to the entire argument(s) and then applies u on the entire result(s) of v .

  • Operand v is executed monadically.
  • Operand u is executed either monadically or dyadically depending whether  u&v has been called monadically or dyadically.

See: More Information for a visual comparison of At (@:), Atop (@), Compose (&) and Appose (&:).

Common Uses


The monadic use of & is deprecated. Use @ instead. Some compounds of the form f&g are not recognized for special code in places where f@g is recognized, if only the monadic form of the compounds is eligible for special treatment.

   *:&+: 3 4 5   NB. double, then square.  Applied to each atom
36 64 100
   *: +: 3 4 5   NB. Same result if applied to entire list
36 64 100
   +/&+: 3 4 5   NB. Double, then "total".  Applied to each atom.
6 8 10
   +/ +: 3 4 5   NB. Not the same if applied to entire list!


   ]firstname =: 'Dennis';'Richard';'Ken'
   ]lastname =: 'Ritchie';'Stallman';'Iverson'
   firstname ,&> lastname   NB. Join each first name to last, individually
   (>firstname) , (>lastname)   NB. very different applied to entire array
   firstname (>@[ , >@])"0 lastname  NB. equivalent form

Related Primitives

Atop (@), At (@:), Appose (&:), Hook ((u v)), Fork ((f g h))

More Information

1. ([x] u&v y) is the same as ([x] u&:v"mv y) (where mv is the monadic rank of v).

The second phrase uses Appose (&:) instead of Compose (&).

An illustration of the process follows, extracted from the series of diagrams referenced below:

flow diagram of the compose conjunction

2. The difference between Appose (u&:v) and Compose (u&v) is shown in the last two columns of the diagram below:


The above diagram also shows At (@:) and Atop (@) for overall comparison.

These four are also visualized along with verb application and rank here: a series of flow diagrams

3. So what's the difference between Atop (@) and Compose (&) ?

None at all, for the monads (u@v) and (u&v)

  u&v y ↔ u v y
  u@v y ↔ u v y
But the dyads are different
  x u&v y ↔ (v x) u (v y)
  x u@v y ↔ u x v y

According to the J Dictionary -- &: is equivalent to & except that the ranks of the resulting function are infinite; the relation is similar to that between @: and @


1. The J Dictionary states that u&v y <==> u v y and x u&v y <==> (v x) u (v y), but these statements assume that u&v is applied at the rank mv as defined above.

The correct equivalences for u&v are given above.

2. Note also that in u&f&v, f will be applied monadically. If the whole expression is called dyadically, then v is applied to each argument, f applied monadically to each result of v, and then u applied dyadically to the results. Equivalent to fork (f@v@[ u f@v@]).