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

Reply via email to