I may be misreading the request, but I think Alex wants: mypoly=: 1 2 3 & p. mypoly 4 57
As Marshall points out, the conjunction "&" connects '1 2 3' to the left argument of 'p.', leaving the usual right argument y to produce a dyadic, albeit with a fixed left argument, result. I find when I return to J, it is usually my assumptions that trip me up. It is frustrating, but once I get those assumptions sorted out, the language generally behaves as expected. ;) Cheers, bob On 2011-04-02, at 9:15 AM, Marshall Lochbaum wrote: > Verbs can't return verbs (sad but true). You want the adverb > > (&p.) > > 1 2 3 (&p.) 4 > 57 > 1 2 3 (&p.) > ------T-T--┐ > │1 2 3│&│p.│ > L-----+-+--- > > Marshall > > -----Original Message----- > From: programming-boun...@jsoftware.com > [mailto:programming-boun...@jsoftware.com] On Behalf Of Alex Gian > Sent: Saturday, April 02, 2011 12:10 PM > To: Programming forum > Subject: [Jprogramming] How to make 'y & p.' a monad? > > Been away from J for a few months, and coming back - I'll be honest - I find > it quite frustrating at how difficult it seems (for me anyway) to get back > into the J mindset. Intuitive is not the first word that springs to mind... > really wish it was. > > Anyway, this is what I was trying to do: > Create a monadic verb that has the effect of mp =: monad : 'y & p.' > The above does not work, giving me a syntax error if I try mp 1 2 3 I also > tried various tacit ways using '~', ']', etc. to no avail. > > All I really want is to have a monadic verb, preferably tacit, but hell, > explicit will do if it works, say, "makepoly" which will create the > polynomial (verb) such that > (makepoly 1 2 3) 4 or > mypoly =: makepoly 1 2 3 > mypoly 4 > will have the same effect as executing > 1 2 3 p. 4 > i.e => 57 > > What have I missed? > > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm