That was exactly the test I ran on nbeta, but I got a different
result:

   f =. [:
   x=: 1e3 [EMAIL PROTECTED] 1e4
   y=: 1e3 [EMAIL PROTECTED] 1e4
   ts 'x ([: +/ >) y'
1.05261e_5 1344
   ts 'x (f +/ >) y'
1.39045e_5 3584

Is your version different?

Henry Rich 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Roger Hui
> Sent: Thursday, May 25, 2006 3:24 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Does (f g h) sneak a peek at f?
> 
> > Experimentation reveals that (f +/ >) above uses the fast
> > code for ([: +/ >), so somehow the initial execution of the
> > hook looked at the value of f, even though only its name is
> > supposed to be available.
> 
> Actually, it does not use the special code for ([: +/ >) :
> 
>    x=: 1e6 [EMAIL PROTECTED] 0
>    y=: 1e6 [EMAIL PROTECTED] 0
>    cap=: [:
>    ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> 
>    ts 'x ([: +/ >) y'
> 0.117277 1344
>    ts 'x (cap +/ >) y'
> 0.13848 1.05011e6
> 
> The array result is the same, of course.
> 
>    x ([: +/ >) y
> 500393
>    x (cap +/ >) y
> 500393
> 
> 
> 
> ----- Original Message ----- 
> From: "Henry Rich" <[EMAIL PROTECTED]>
> To: "'Programming forum'" <[email protected]>
> Sent: Thursday, May 25, 2006 11:14 AM
> Subject: [Jprogramming] Does (f g h) sneak a peek at f?
> 
> I suspect only Roger can elucidate this.
> 
>    x=: 1e3 [EMAIL PROTECTED] 1e4
>    y=: 1e3 [EMAIL PROTECTED] 1e4
>    f =: [:
>    $ x (f +/ >) y
> 
> Interesting.  Why wasn't f executed, giving a domain error?
> Experimentation reveals that (f +/ >) above uses the fast
> code for ([: +/ >), so somehow the initial execution of the
> hook looked at the value of f, even though only its name is
> supposed to be available.
> 
>    f =: ff
>    ff =: [:
>    $ x (f +/ >) y
> |domain error: ff
> |   $x    (f+/>)y
> 
> Apparently the look goes down only one level.  Is this so
> someone can assign   cap =: [:   and use it?  But it violates
> the normal rules.  With f as defined above, I can write
> 
>    f =: ff
>    ff =: [:
>    s =: 4 : 0
> f =: +
> x > y
> )
>    $ x (f +/ s) y
> 1000 1000
> 
> which is correct: executing s modified the value of f, and the
> modified value was used, avoiding the domain error.  But if
> f is defined as [:, the modified value is not used:
> 
>    f =: [:
>    $ x (f +/ s) y
> 
> See?  It executed as if f were [:
> 
>    $ x (f +/ s) y
> 1000 1000
> 
> Second time through, it uses the changed f.
> 
> It looks like f in (f g h) is inspected to see if it is [:, and
> if it is, special steps are taken.  If this is so, it should
> be documented.  But it seems a kludge to me, and I think the
> special case should be removed (I have an interest in this, because
> whether you document it or not, I have my book to think about).
> 
> If someone wants cap, let 'em write [: .
> 
> 
> ----------------------------------------------------------------------
> 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