Did you try tacit verb? (Sorry if duplicated, hard to follow the thread) is=: [: ". [ , '=:' , ] 'v1' is '+/ % # '
v1 3 4 5 4 isV=: [: ". [ , '=: 3 : '' ' , ] , ' '' '"_ 'v3' isV '2+y' v3 3 : ' 2+y ' v3 4 6 I believe the advantage of tacit with '=.' is that it will allow to assign likewise locally within an explicit scope. > From: "Sherlock, Ric" <[email protected]> > > I was about to post this as a question but finally figured out the answer. > I'll > post it anyway in case it is of help to others: > > I want to create a verb "defverb" such that > 'myname' defverb '' > assigns to a new verb 'myname' > > So if was: > % *: y > I'd end up with a monadic verb called myverb that took the right argument, > squared it and found the reciprocal. > > ('myverb')=: 3 : '% *: y' NB. This works > > tstx=: 'myverb2' > tsty=: '% *: y' > (tstx)=: 3 : tsty NB. This works > > verbstr=: 4 : '(x)=: 3 : y' NB. define verb to do it > verbstr > 4 : '(x)=: 3 : y' NB. looks ok > 'myverb3' verbstr '% *: y' NB. Doesn't work! > |syntax error: verbstr > | 'myverb3' verbstr'% *: y' > > Why? > > > > > > > > An explicit verb is only allowed to return a noun. > > Solution. > verbstr=: 4 : ('(x)=: 3 : y';'$0') > > 'myverb3' verbstr '% *: y' > myverb3 4 3 > 0.0625 0.111111 > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
