Thanks everyone for your very useful answers ; I've now halved my code by replacing monads with dyads where appropriate.
I can see I've got a way to go in understanding the finer points of verb composition esp when looking at Raul's proposed solution annmatch=: (i.>./)@((+/)@e.&>"0 1) Raul in answer to your question no actually the output didn't need to be boxed and the above definition works superbly ; though I'll need to further understand this type of verb before I use it ; I'm guessing this is what you call a tacit verb ? seems quicker than using 3 : 0 and 4 : 0 as well. Cheers John -----Original Message----- From: Sherlock, Ric [mailto:[EMAIL PROTECTED] Sent: Saturday, 30 August 2008 3:41 AM To: Programming forum Subject: [Jprogramming] RE: Create Dyad ? ---Saunders, John wrote: > > Hi guys I have the below verb annmatch and would like to make it a dyad > the noun bals is what I want to replace with an X value so I can make > this more flexible and not tied to bals ; just not exactly sure how to > go about it ; hope I'm making sense and using the appropriate j- > language > here. In addition to the helpful advice already given, you might find the following wiki page useful: <http://www.jsoftware.com/jwiki/Guides/Defining_Verbs> Note also (the following is a transcript from a J session) dyad NB. this pre-defined when your session starts 4 define NB. so is this :0 NB. Therefore: MyDyadicVerb=: dyad define x + y ) Is equivalent to: MyDyadicVerb=: 4 :0 x + y ) NB. Similarly: MyMonadicVerb =: monad define 2 * y ) NB. is equivalent to: MyMonadicVerb =: 3 :0 2 * y ) NB. It is less confusing to use "verb" instead of "monad" when NB. defining a verb with both monadic and dyadic cases, although NB. they are both just covers for 3: 3 = monad , verb 1 1 MyVerb =: verb define 2 * y : x + y ) ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
