Dan Bron wrote:
> 
> Igor Zhuravlov has proposed a language extension to specifically address
> this problem:  
> 
>        Proposal:
> http://www.jsoftware.com/jwiki/System/Interpreter/Requests#extendEvokeGerund 
>        Details:   
> http://www.jsoftware.com/jwiki/IgorZhuravlov/Extended%20forks 
>        Script:      
> http://www.jsoftware.com/jwiki/IgorZhuravlov/Extended%20forks?action=AttachFile&do=get&target=fork.ijs
>  
> 
> This is a very exciting idea to me, but I've yet to play with it enough to
> make any further comments.  But AFAIK the problem you
> describe is intrinsic to the language as it is defined today.
> [...]
> 

Let's consider 3-forks.  Their straightforward implementation is:

   fork3 =: (a0 b0 a1)c(a1 b1 a2)

Now the only potential problem I see here is that a1 is evaluated twice.
So we optimize it by boxing:

   fork3a =: a1 ((b0~ >@{.) c (b1 >@{:)) a0 ; a2

If a1 is really expensive, then overhead due to boxing evaporates,
and fork3a is faster than fork3, up to a factor of 2.

The gerund form of fork3 is:

   fork3ger =: a0`a1`a2`b0`b...@.((<0 3 1);5;<1 4 2)

Finally, if we define the tacit adverb part as:

   Fork3 =: @.((<0 3 1);5;<1 4 2)

we get the solution in the form that Igor (Hi Igor!) sought as:

   a0`a1`a2`b0`b1`c Fork3

So, is any of these solutions satisfactory?

The Igor's example:

   a0=:+
   b0=:%:
   a1=:-    NB. a1 is inexpensive compared to the rest of the verbs.
   c =:%
   b1=:^
   a2=:*

   fork3 f.
(+ %: -) % - ^ *

   fork3a f.
- ((%:~ >@{.) % (^ >@{:)) + ; *

   a0`a1`a2`b0`b1`c Fork3 f.
(+ %: -) % - ^ *

    2 fork3 4
0.00379719j0.00219231
   2 fork3a 4
0.00379719j0.00219231
   2 a0`a1`a2`b0`b1`c Fork3 4
0.00379719j0.00219231
-- 
View this message in context: 
http://old.nabble.com/Handling-%22deep%22-values-in-tacit-form.-tp27149526s24193p27166917.html
Sent from the J Programming mailing list archive at Nabble.com.

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

Reply via email to