Distribute composition over gerunds:

dcog =: 1 : ' 2 : (''v1=.{.^:(1 -: #)@:}:'' ; ''(v1 u`[) ((,'' , (5!:5{.;:''m'') , '') <@; <)@,"0 (v1 v`])'') '

This adverb emulates and extends the undocumented, pre-J601c behavior of compositions with gerund. The J-implemented restricted compositions with gerunds to the forms:

           [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]   m@:v u@:n m@:n   m&:v 
u&:n m&:n   m&n

But dcog can distribute any conjunction. In particular, '&.' dcog will probably find many uses.

Example:

           At     =:  '@'  dcog
           Atop   =:  '@:' dcog

           1:    At  3:
           1:`2: At  3:
           1:    At (3:`4:)
           1:`2: At (3:`4:)

           First  =:  Atop {.
           Across =:  First (;.1)~  (` 1:    ) (`:6)

The adverb Across provides an answer to one of the FAQs on this list: you can use it to apply a list of verbs (a gerund) to a corresponding list of nouns (the gerund will be extended cyclically if required). Silly example:

                +:`-:`*:`%: Across  i. 4*3
        0 0.5 4 1.73205 8 2.5 36 2.64575 16 4.5 100 3.31662

So, this definition answers Oleg's question:

    http://www.jsoftware.com/pipermail/programming/2006-November/004188.html

in a J601c-compatible way (superseding the (@:{.)(;.1)~(`1:)(`:6) I'd given previously).

Furthermore, the definitions:

           Each         =:  '&.' dcog >
           AcrossBoxed  =:  Each Across

Can stand in for the corresponding entities in the HTML Publishing script:

           NB.  cover for &.>
           NB.  (required as  &.  doesn't handle gerunds)
           Each=: (<@) (@>)

           NB.  across - apply gerund left to array on right.
           across=: adverb def '1 (  ({.([EMAIL PROTECTED] $ ,)`[)  A   u  );.1 
]'

In a J601c-compatible way.

-Dan

PS: Yes, dcog is ugly, but I like to think of it as Messiah Code: it's ugly so that other code doesn't have to be. A sponge for sin.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to