I see that I misunderstood the accgen problem.

very surprised to hear that a closure must refer to an
object.  I'm pretty comfortable with
currying/partially applying a function to return a
function satisfies the requirements of a closure, and
languages without object systems or one's with OOP
tacked on late in their evolution cycle (such as
lisp/scheme) throw around the term closure in ways I
understand to refer to functions.

It boils down to problem definition.  The function is
supposed to keep track of n (updating it) on each call
 then yes,  an object is part of the only solution. 
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.


--- Stefano Lanzavecchia <[EMAIL PROTECTED]> wrote:

> > --- Vladimir Lazunin <[EMAIL PROTECTED]>
> > wrote:
> > 
> > > Is it possible to make that in J?
> > > http://www.paulgraham.com/accgen.html
> 
> > verbs cannot return verbs.
> > adverbs and conjunctions can.
> > 
> > (7&+) is a function (verb).  It is the same as the
> > add7 verb in Chris's example solution.  if n is
> the number in the 
> > graham challenge, then (n&+) is a fine solution.
> > 
> > (&+) is an adverb. Adverbs take argument on left.
> > 7 (&+) "evaluates" to the verb (7&+).
> >  (7&+) 100
> > 107
> >  7 (&+) 100
> > 107
> > IMO, the better accgen challenge submission for J
> is, n (&+)
> > --> n (&+) i or if you had to:
> > foo =: 1 : 'm (&+)'
> > 
> > The general solution to creating a function
> returning a function is to 
> > define an adverb or conjunction to do it.
> 
> What is actually required to meet Graham's challenge
> is not to return a
> function (or verb) but a closure. The challenge was
> discussed on this same
> maillist not long ago: I do recommend checking its
> archive. If I remember
> correctly the only possible solution is to use J's
> OO extensions. In many
> occasions closure are converted to objects when
> compiling from an FP
> language to an OO language. J is not an FP language
> in the now expected
> meaning so it's better to consider it an OO language
> for the class of
> problems that can be solved with explicitely
> returning closures in
> traditional FP languages.
> --
> WildHeart'2k6 - mailto:[EMAIL PROTECTED]
> My digipics and blogs:
> http://spaces.msn.com/members/wildy2k5/
> 
> [[All I Ever Learned, I Learned From Anime: //
>   Honor is sexy; villainy is irresistable.]]
> 
>
----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to