Hi Pawel,

datatype is a verb defined in the z locale that might do what you require

   datatype 's'
literal
   datatype 0
boolean
   datatype
3 : 0
n=. 1 2 4 8 16 32 64 128 1024 2048 4096 8192 16384 32768 65536 131072 262144
t=. '/boolean/literal/integer/floating/complex/boxed/extended/rational'
t=. t,'/sparse boolean/sparse literal/sparse integer/sparse floating'
t=. t,'/sparse complex/sparse boxed/symbol/unicode/unicode4'
(n i. 3!:0 y) pick <;._1 t
)
   

or you could use the 3!:0 foreign conjunction that is at the core of the 
functionality and returns the powers of 2 identifiers.

Cheers, bob

> On Sep 10, 2022, at 11:49, Pawel Jakubas <jakubas.pa...@gmail.com> wrote:
> 
> Dear J users,
> 
> What is the way to detect number that could be represented as integer,
> float, could be negative, could assume scientific notation or rational. Is
> there something like isNumber or isString ?
> I would like to have something like this:
> 
> if. (detect_number i) do.
>    process number
> else.
>    process string
> 
> and detect_number to survive inputs
> i=: 2
> i=: _2
> i=: 2r3
> i=: 2.3333
> i=: 4.29497e9
> i=: 'Two'
> 
> Thanks and cheers,
> Pawel
> ----------------------------------------------------------------------
> 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