>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary

13. Compositions (Based on Conjunctions)

In math, the symbol ° is commonly used to produce a function defined as the composition of two functions: f ° g y is defined as f (g y) . Normally, such composed functions are only defined to apply to a single scalar argument.

J provides compositions effected by five distinct conjunctions, as well as compositions effected by isolated sequences of verbs: hooks and forks, and longer trains formed from them. The five conjunctions are & &. &: @ and @: , the conjunctions @ and @: being related in the same manner as & and &: .

The conjunction & is closest to the composition ° used in math, being identical to it when used for two scalar (rank zero) functions to produce a function to be applied to a single scalar argument. However, it is also extended in two directions:

1.   Applied to one verb and one noun it produces a monadic function illustrated by the cases 10&^. (Base ten logarithm) and ^&3 (Cube).
2. Applied to two verbs it produces (in addition to the monadic case used in math) a dyadic case defined by: x f&g y (g x) f (g y) . For example, x %&! y is the quotient of the factorials of x and y .

The conjunction &. applies only to verbs, and f&.g is equivalent to f&g except that the inverse of g is applied to the final result. For example:
   3 +&^. 4                      3 +&.^. 4
2.48491                       12
For scalar arguments the functions f&:g and f&g are equivalent, but for more general arguments, g applies to each cell as dictated by its ranks. In the case of f&g, the function f then applies to each result produced; in the case of f&:g it applies to the overall result of all of the cells. For example:
   (] ; %. ; |:&%. ; |:&:%.) i. 2 2 2
|0 1|_1.5 0.5|_1.5  1|_1.5 _3.5|
|2 3|   1   0| 0.5  0|   1    3|
|   |        |       |         |
|4 5|_3.5 2.5|_3.5  3| 0.5  2.5|
|6 7|   3  _2| 2.5 _2|   0   _2|
The conjunctions @ and & agree in the monadic case, as indicated below for cells x and y as dictated by the ranks of g :

  f&g y f g y
  f@g y f g y
x f&g y (g x) f (g y)
x f@g y f (x g y)

>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Rel  Voc  !:  Help  Dictionary