Viktor's way is OK, but I have had performance trouble with `...@.
especially on rank 0.

I would use

^.@:([:^:(errorcondition))"0

or, better, if you don't need the verb to be rank 0,

^.@([:^:(errorcondition))

where you can do everything on arrays

errorcondition =. 0&>: +. _&<: +. 0 ~: 11&o.  NB. scalar
errorcondition =. [: +./@, 0&>: +. _&<: +. 0 ~: 11&o.  NB. array

If you want a custom error, use 13!:8 instead of [:

untested.

Henry Rich


Kip Murray wrote:
> How do you check arguments for a tacit verb?  Say it's monadic"0 and I 
> want the argument to be real and positive excluding _ (infinity).  If 
> no, halt with an error message; if yes, process the argument, say take 
> the natural logarithm.  /Kip Murray
> 
> 
> ------------------------------------------------------------------------
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to