http://www.jsoftware.com/jwiki/Essays/The%20Ball%20Clock%20Problem

assert=: 13!:8@(12"_)^:-.

Addition effects can be obtained by composition with [ or ]



----- Original Message -----
From: Henry Rich <[email protected]>
Date: Tuesday, May 26, 2009 7:46
Subject: Re: [Jprogramming] Tacit argument checking
To: Programming forum <[email protected]>

> 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

Reply via email to