This will be fun to have. I don't "think" in expressions that are this long
but I hope to get it glued together and try it.

You made this comment about me: (as I noticed you like 13 : n so much for
mechanically converting explicit to tacit)

I really don't care as much about the tacit result as I do about having a
record of where the  arguments belong in the expression. This explicit form
is most instructive to me at this stage. It is a good way to begin to
capture your ideas and generate code that extends the use of your
expressions.

As I read and write more  J I may or may not begin to "think" in tacit
expressions. Or the idiomatic versions with lots of idioms using  @  may
become easier. 

Linda

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Beh alf Of Dan Bron
Sent: Friday, February 10, 2012 6:53 PM
To: 'Programming forum'
Subject: Re: [Jprogramming] Another early morning exercise

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

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

Reply via email to