Lots of the simple examples are easy:
D=:'0123456789'
warn=: [EMAIL PROTECTED]:]
'has nondigits' warn 0 e.y e.D
'not a natural number' warn 0 e.y e.D
'not an integer' warn 0 e. (y }.~({.y)e.'-')e.D
'not an integer' warn 0 e. (y }.~({.y)e.'-+')e.D
However, a number of the more complicated ones are specifically
designed around the features and limitations of regular expressions,
so you should probably use pcre for those.
but the page does not show how to convert strings to numbers.
Use ". -- and use a numeric left argument if you want just numeric
conversion rather than full eval.
If you want some base other than 10, prefix your numeric word with
an appropriate tag (and, if needed, convert upper case letters to
lower).
octal=: _. ". [: ; (<' 8b'),&.> a: -.~ ' '<;._1@,]
octal '1.1 10 -777'
1.125 8 _511
require 'strings'
undecimal=: _. ". [: ; (<' 11b'),&.> a: -.~ ' '<;._1@,tolower
undecimal '1.1 10 -777'
1.09091 11 _931
That said, note that letters are treated as digits when you use this
technique, regardless of what base you're working with:
undecimal '1e20 1 e 10 deadbeef'
3047 1 14 11 279952424
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm