[: Cap

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

Cap | [: _ _ _ | Cap

`[:` caps a left branch of a fork, as described in Section II F. For example, the function`p=: [: +/ + * -` applies the monad`+/` to the result of the fork`+ * -` .

Caps make it possible to define a wider range of functions as unbroken trains. For example, the maximum divided by the product of the sum and difference would be defined by a single train, whereas (without the use of the cap) the definition of the maximum divided by the (monad) floor of the product of the sum and difference would require the use of trains interrupted by the monad. Thus:

       f=: >. % + * -
       g=: >. % <. @ (+ * -)

       2.5 f 4
    _0.410256

       2.5 g 4
    _0.4

The cap makes possible the use of an unbroken train as follows:

       h=: >. % [: <. + * -

       2.5 h 4
    _0.4

Since the domain of the cap is empty, it can be used (with`:`)`` to define a function whose monadic or dyadic case invokes an error. For example:

       abs=: | : [:
       res=: [: : |

       res _4 0 5
    |valence error: res
    |       res _4 0 5

       abs _4 0 5
    4 0 5

       3 res _4 0 5
    2 0 2

       3 abs _4 0 5
    |valence error: abs
    |   3     abs _4 0 5

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