This verb naturally operates on atoms. So you need to tell the interpreter that:
phi=: 3 : 'y%#(>:i.y)-.,(>:i.y)*/(y$q:y)'"0 Then phi will be extended to higher ranks by the usual means. To understand the usual means, see the Dictionary or JfC ( http://www.jsoftware.com/help/jforc/loopless_code_i_verbs_have_r.htm#_Toc191734331 ) Henry Rich On 9/11/2011 9:20 PM, David Vaughan wrote: > Hi, > > I have defined a verb like so: > > phi=: 3 : 'y%#(>:i.y)-.,(>:i.y)*/(y$q:y)' > > It seems I can only use with atoms, e.g. > > phi 6 > 3 > > What I want to be able to do, is apply this verb to a list. I would also like > to know how I can define verbs so they can be more flexible in this way in a > general sense. > > This is the output of my failed attempt: > > phi i.6 > |domain error: phi > | y%#(>:i.y)-.,(>:i.y)*/(y$ q:y) > > I can kind of see where the problems may be, but I can't think how to > eradicate them - this is the sort of thing I would usually be just using > loop for in a C type language, but I would dearly love to know the best J > style approach. Also, I find that these error messages are difficult to > interpret - I'm not clear where the error has been found, but I assume the > large space has something to do with it (any advice here would be helpful). > > Thanks in advance. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
