Re: [Jprogramming] detect number but survive also string input

2022-09-11 Thread 'Mike Day' via Programming
Doesn’t “unsubscribe” in the subject field do the trick for you?  
If you’re really sure you want to leave us...

M

Sent from my iPad

> On 11 Sep 2022, at 16:28, lb_tay...@charter.net wrote:
> 
> Hello.Could you please remove me from this distribution list for
> now?Thank you.Sallie
> 
>-From: "Raul Miller" 
> To: programm...@jsoftware.com
> Cc: 
> Sent: Saturday September 10 2022 3:55:42PM
> Subject: Re: [Jprogramming] detect number but survive also string
> input
> 
> I would use (0&". -: 1&".) or some variation which deals with the
> cases you're interested in for this purpose.
> 
> Thanks,
> 
> --
> Raul
> 
>> On Sat, Sep 10, 2022 at 2:49 PM Pawel Jakubas  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.
>> 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
> />
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] detect number but survive also string input

2022-09-11 Thread lb_taylor
Hello.Could you please remove me from this distribution list for
now?Thank you.Sallie

-From: "Raul Miller" 
To: programm...@jsoftware.com
Cc: 
Sent: Saturday September 10 2022 3:55:42PM
Subject: Re: [Jprogramming] detect number but survive also string
input

 I would use (0&". -: 1&".) or some variation which deals with the
 cases you're interested in for this purpose.

 Thanks,

 --
 Raul

 On Sat, Sep 10, 2022 at 2:49 PM Pawel Jakubas  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.
 > 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
 />
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] detect number but survive also string input

2022-09-10 Thread bill lam
test whether operations for numbers failed , but
not particularly efficient

try. 0+ i
do number
catch.
do string
end.

On Sun, 11 Sep 2022 at 2:49 AM Pawel Jakubas 
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.
> 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


Re: [Jprogramming] detect number but survive also string input

2022-09-10 Thread Raul Miller
I would use (0&". -: 1&".) or some variation which deals with the
cases you're interested in for this purpose.

Thanks,

-- 
Raul

On Sat, Sep 10, 2022 at 2:49 PM Pawel Jakubas  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.
> 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


Re: [Jprogramming] detect number but survive also string input

2022-09-10 Thread 'Pascal Jasmin' via Programming
maybeton =: 0&".^:('0'&-: +. 0 -.@-: 0&".) 0&".^:('0'&-: +. 0 -.@-: 0&".) 


 maybeton '3 22r4'

3 11r2

maybeton '3e2 22r4 two'  NB. asking too much

300 5.5 0

maybeton 'two2'

two2


On Saturday, September 10, 2022 at 02:49:30 p.m. EDT, Pawel Jakubas 
 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.
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


Re: [Jprogramming] detect number but survive also string input

2022-09-10 Thread 'robert therriault' via Programming
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  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.
> 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


[Jprogramming] detect number but survive also string input

2022-09-10 Thread Pawel Jakubas
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.
i=: 4.29497e9
i=: 'Two'

Thanks and cheers,
Pawel
--
For information about J forums see http://www.jsoftware.com/forums.htm