RosettaCodeData/Task/Determine-if-a-string-is-numeric/Toka/determine-if-a-string-is-numeric.toka
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

10 lines
444 B
Text

[ ( string -- flag )
>number nip ] is isNumeric
( Some tests )
decimal
" 100" isNumeric . ( succeeds, 100 is a valid decimal integer )
" 100.21" isNumeric . ( fails, 100.21 is not an integer)
" a" isNumeric . ( fails, 'a' is not a valid integer in the decimal base )
" $a" isNumeric . ( succeeds, because $ is a valid override prefix )
( denoting that the following character is a hexadecimal number )