> > Only because of the need for a static variable. Pretty hard
> to come up
> > a non-object version for handling static variables, but I
> maintain its
> > unrelated to closures.
> 
> I agree with p j.
> 
> Here's an implementation which does not use closures nor objects:
> 
> ".(0>nc<'N')#'N=:a:'
> acc=:3 :0
>  n=.":#N
>  N=:N,<y
>  3 :('n{::N=:N n}~<y+N{::~n=.',n)`''
> )
> 
> Example use:
>    f=: (acc 7)`:0
>    f 3
> 10
>    f 3
> 13
> 

It uses a closure. You are polluting the global namespace to keep track of
your counter. In fact, closures as traditionally intended would hide the
pollution in their local namespace (therefore an object). So your closure is
the entire J session.
--
WildHeart'2k6 - mailto:[EMAIL PROTECTED]
My digipics and blogs: http://spaces.msn.com/members/wildy2k5/

[[Mou sugu o-furo dakara issho ni hairou  //
  I'm about to take a bath, so let's go in together]]

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

Reply via email to