I would be inclined to do something similar:

numeric=: 0  =  0 {.@{. ,

That said, it's usually sufficient to rely on domain errors for this
kind of thing.

Thanks,

-- 
Raul






On Thu, Nov 9, 2017 at 12:20 PM, Michael Berry <[email protected]> wrote:
> Hello J world,
>
> I have a verb that returns scalar 1 if the argument is numeric of any shape
> and scalar 0 otherwise.
> It works fine:
>
>    numeric i. 5
>
> 1
>
>    numeric 9
>
> 1
>
>    numeric i. 2 3 4
>
> 1
>
>    numeric 'cat'
>
> 0
>
>    numeric 3#<i. 4
>
> 0
>
>
> My definition feels clumsy, however. Can anyone suggest something nicer?
>
>
> numeric=: monad : '0 -: 0{ , 1{. 0#y'
>
>
> -Michael
> ----------------------------------------------------------------------
> 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