[Jprogramming] detect number but survive also string input
Raul Miller
rauldmiller at gmail.com
Sat Sep 10 20:55:12 UTC 2022
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 <jakubas.pawel at 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
More information about the Programming
mailing list