>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Phrases

# 2C. Adverbs and Conjunctions

Adverbs from Conjunctions

A conjunction together with one of its arguments produces an adverb defined in an obvious way. For example, if `a1=: &3`, then `^ a1` is equivalent to `^&3 3` (the cube function), and if `a2=: 3&` then `^ a2` is equivalent to `3&^` (the three-to-the-power function). It is therefore easy to define useful families of adverbs from a conjunction, so easy that it is fruitless to attempt an exhaustive catalogue. The following list is intended to suggest the possibilities in various classes:

`a0=: I=: ^:_1` | Inverse `(^I` is `^.)`
`a1=: L=: ^:_` | Limit `(2&o.L 1` for soln of y=cos y)
`a2=: LI=: ^:__` | Limit of inverse
`a3=: SQ=: ^:2` | Square `(1&o.SQ` for sine squared)
`a4=: C=: &o.` | Family of circular `fns (3 C` is tangent)
`a5=: CO=: %@C` | `3 CO` is cotangent
`m6=: rfd=: 1r180p1&*` | Radians from degrees
`m7=: dfr=: rfd I` | Use `dfr=: dfr f.` to fix definition
`a8=: D=: @rfd` | Try `1 C D 0 30 45 60 90 180`
`m9=: SIN=: 1&o. D` | Sine for degree arguments
`a10=: T=: "2` | Try `<T I. 2 3 4 3` (BOX TABLES)
`a11=: S=: ^!.` | Stope (rising or falling factorial fn etc)
`a12=: P=: p.!.` | Stope polynomial
`a13=: FILL=: |.!.` | Fill for shift (non-cyclic rotate)
`a14=: FILE=: 1!:` | File functions (`1 FILE` for read, etc.)

Explicit Definitions

An adverb or a conjunction can be defined in explicit form. For example:

       split=: 2 : ',.@(x.@(y.&{.) ; x.@(y.&}.))'
       ]x=: i. 5 3
     0  1  2
     3  4  5
     6  7  8
     9 10 11
    12 13 14

       (+: split 2 ,. |. split 3 ,. +/ split 2) x
    +--------------------------+
    ¦0 2  4  ¦6 7 8   ¦3 5 7   ¦
    ¦6 8 10  ¦3 4 5   ¦        ¦
    ¦        ¦0 1 2   ¦        ¦
    +--------+--------+--------¦
    ¦12 14 16¦12 13 14¦27 30 33¦
    ¦18 20 22¦ 9 10 11¦        ¦
    ¦24 26 28¦        ¦        ¦
    +--------------------------+

`c15=: split=: 2 : ',.@(x.@(y.&{.) ; x.@(y.&}.))'` | split as defined above
`d16=: by=: ' '&;@,.@[,.]` | Verb for use in the`table` adverb below
`d17=: over=: ({.;}.)@":@,` | Verb for use in the`table` adverb below
`a18=: table=: 1 :'[ by ]over x./'` | Try `1 2 3 * table 4 5 6 7`

Noun Arguments

Adverbs that apply to a noun argument, and conjunctions that apply to one noun argument and one verb argument are commonplace. For example:

       x=: 0 0 1 1 [ y=: 0 1 0 1
       x *. y			Boolean and
    0 0 0 1

       x 1 b. y			Boolean adverb
    0 0 0 1

       x (i.16) b. y		All sixteen Boolean functions
    0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
    0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
    0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
    0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

       C=: 1 : 'x.&o.'              Circle adverb
       1 C 0 1r4p1 1r3p1 1r2p1 1p1	Sine function
    0 0.7071068 0.8660254 1 0

       ^&3 x=: i. 6	 		Cube
    0 1 8 27 64 125

       2 |. !. 1 x			Shift in ones
    2 3 4 5 1 1

Conjunctions that apply to two nouns are less familiar, although the definitions of functions in terms of nouns occur frequently in math. For example, a rational function (the quotient of a polynomial `a&p.` divided by another `b&p.`) is defined by a pair of coefficients. Thus:

       a=: 1 4 6 4 1 [ b=: 1 2 1
       RAT=: 2 : 'x.&p. % y.&p.'
       a RAT b
    1 4 6 4 1&p. % 1 2 1&p.

       a RAT b y=: i.6
    1 4 9 16 25 36

       b RAT a y
    1 0.25 0.111111 0.0625 0.04 0.0277778

       (a RAT b * b RAT a) y
    1 1 1 1 1 1

We may also remark that expressions such as 2 x3 and 2 x3 + 4 x2 are commonly used in elementary math to define functions rather than to indicate explicit computation: the x in the foregoing can be construed (and defined) as a conjunction such that 2 x 3 is the function `2:*]^3:` . Thus:

       x=: 2 : 'x.&* @ (^&y.) " 0'
       2 x 3
    2&*@(^&3)"0

       2 x 3 y=: 0 1 2 3 4 5
    0 2 16 54 128 250

       2 * y ^ 3
    0 2 16 54 128 250

       2 3 5 x 1 2 4 y
     0  0    0
     2  3    5
     4 12   80
     6 27  405
     8 48 1280
    10 75 3125

The last result above gave the values of the individual terms; in order to obtain their sums (and yet retain the behaviour for a single term), we redefine the conjunction x as follows:

       x=: 2 : '+/ @ (x.&* @ (^&y.)) " 0'
       2 3 5 x 1 2 4 y
    0 10 96 438 1336 3210

       (2 x 1 + 3 x 2 + 5 x 4) y
    0 10 96 438 1336 3210

       2 x 3 y
    0 2 16 54 128 250

`c19=: RAT=: 2 : 'x.&p. % y.&p.'` | Produces rational function
`c20=: x=: 2 : '+/ @ (x.&* @ (^&y.)) " 0'` | Mimics notation of elementary math
`c21=: bind=: 2 : 'x. @ (y."_)'` | Binds `y` to the monad `x`

It is often convenient to bind an argument to a monad, producing a function that ignores its argument. For example, using`wdinfo` ,`` a monad that displays its argument in a message box, the definition`fini=: wdinfo bind 'Job Finished'` produces a function such that`fini''` is equivalent to`wdinfo 'Job Finished'` .

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Phrases