a pretty flexible templating tool that generates sensible interpretations for 
a(dverb) c(onjunction) trains (and their reverse).  Its a templating tool 
because there's no restriction on the parameters, despite the ac and ca names.

ca =: 2 : ' 2 : (''u '' , u  , ''('' , '' v '' , v  , '')'' )'ac =: 2 : ' 2 : 
(''(u '' , u  , '')('' ,  v  , '' v '' ,'')'' )'

     '/' ac '@'
2 : '(u /)(@ v )'
  

  '/' ca '@:'
2 : 'u /( v @:)'


the main difference between the 2 is that v is placed prior to string on ca, 
and after the string on ac.  The only other difference is that ca does not 
bracket the resulting "u c" side.  This bracketing can be useful, so here is an 
additional definition

acS =: 2 : ' 2 : (''(u '' , u  , '')('' , '' v '' , v  , '')'' )'

    +'/ % #' acS '@' -:

-:@(+/ % #)

  +'/ % #' ac '@' -:
(+/ % #)@-:


without the bracketing, ca results in the weird but perhaps intentional:


    +'/ % #' ca '@' -:
+/ % -:@#
  

both are conjunctions that return conjunctions.  Its possible for the returned 
conjunction to return an adverb rather than a verb.  For example

   3&* +'/@' ca '@' -: 
-:@(+/@(3&*))

its a general templating tool because you can do stuff like:

     '' ac '+/ %'   

2 : '(u )(+/ % v )'
NB. if v is a verb template (or adverb). ac result can only be a hook, and u 
has to be '' or verb or adverb.

    ] '' ac '+/ %' #
] (+/ % #)
  
+ '/+' ca ' % #' (+/)  NB. the reason ca doesn't parenthesize is to make trains.

+/ + +/ % #

passing aa to ca works like the above verb parameters.  A hook results.


     + ']' ac '+/ % ' (#)
(+ ]) (+/ % #)
   + ']' acS '% #' (+/)
(+ ]) (+/ % #)
   10 + ']' ac '+/ % ' (#) 1 2 3
12

has all the benefits of partial bonding of conjunctions, and pretty easy to 
debug.


an adverb version of ac has some simplicity to it, and can do the same as ca.


acA =: 1 : ' 2 : (''u '' , u  , ''('' ,  '' v '' ,'')'' )'

  + '/@' acA +:
+/@+:
  +: '+ + -' acA +
+: + + - +

unlike ac, acA cannot take 2 conjunctions as params.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to