Linda wrote:
>  I was trying to find a situation where you have to 
>  use  @  instead ( of [: ).
 
I think Raul pointed out that u@v <=> ([: u v)"v so that you never /have/ to 
use @ .  You can mechanically convert from one formulation to the other.  So I 
figured I'd provide you a tool to do just that (as I noticed you like 13 : n so 
much for mechanically converting explicit to tacit). 
 
The adverb Cap, defined below, takes a verb argument, and derives a verb 
identical in function, but removes all mentions of @ , and substitutes [: for 
glue.  Well, the derived verb is not identical in all situations; in 
particular, instead of imposing the u@v <=> ([: u v)"v rule universally, I 
tried to simplify this to  [: u v  where possible, to reduce the noise factor 
(at the cost of a result which is not identical under all situations, just the 
most common uses). 
 
The adverb is all one line (fully fixed functional form!) but to get it safely 
through email I've line-wrapped it.
 
   ". noun define -. CRLF
      Cap_z_ =: ((<":0)`) (<`) ((<@((3 (":@:[ <@,&< ]) [:`'' , ]) 
    (<@(({.;:'"') (,<) ,&{:~) {::~ ('';1;0) }.~ _2 * 0 {:: [)~ (0 
    +./ .>~^:] _1 |. 1:`'' , ([: |.&.>&.> (;:'@[b.') <@((,<)/)@:,"
    1 0 ])) ; {:)^:(2=#)@:>@:{:^:((({.;:'@')={.) *. (2=#))@:($:&.>
    )^:(0 < L.))`) (@.(0;1;2 3)) (`:6)
)
 
Examples:
   
   f@g Cap
[: f g
   
   f@g@h Cap
[: ([: f g) h
   
   f@(g@h) Cap
[: f [: g h
   
   
   (+/ +: % #) Cap  
+/ (+: % #)
   
   (+/ +:@% #) Cap
+/ ([: +: %) #
   
   
   {.@$ Cap
[: {. $
   
   {.@+. Cap
([: {. +.)"0 0 0
   
   <@%. Cap
([: < %.)"2 _ 2
   
   %.@< Cap
([: %. <)"_ 0 0
   
 
But if you take the bait, watch for the hook: I wrote this tool which "avoids 
@", so that we don't need to have any more discussions about how to do that, 
challenges which impose it as a constraint, or extended threads regarding the 
right-to-leftness of composition in J.  Deal?
 
-Dan 
 
PS:  Note that due to a bug in 5!:5, typing Cap in the IJX window results in a 
domain error.  So, for those who wish to peek behind the veil, the source 
material is here:  
http://www.jsoftware.com/svn/DanBron/trunk/environment/at2cap.ijs  .  Adverbial 
programmers might find a tool or two worth adding to their kits.  


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

Reply via email to