> --- 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
