Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,3 +0,0 @@
|
|||
package Numeric_Tests is
|
||||
function Is_Numeric (Item : in String) return Boolean;
|
||||
end Numeric_Tests;
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package body Numeric_Tests is
|
||||
function Is_Numeric (Item : in String) return Boolean is
|
||||
Dummy : Float;
|
||||
begin
|
||||
Dummy := Float'Value (Item);
|
||||
return True;
|
||||
exception
|
||||
when others =>
|
||||
return False;
|
||||
end Is_Numeric;
|
||||
end Numeric_Tests;
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Numeric_Tests; use Numeric_Tests;
|
||||
|
||||
procedure Is_Numeric_Test is
|
||||
S1 : String := "152";
|
||||
S2 : String := "-3.1415926";
|
||||
S3 : String := "Foo123";
|
||||
begin
|
||||
Put_Line(S1 & " results in " & Boolean'Image(Is_Numeric(S1)));
|
||||
Put_Line(S2 & " results in " & Boolean'Image(Is_Numeric(S2)));
|
||||
Put_Line(S3 & " results in " & Boolean'Image(Is_Numeric(S3)));
|
||||
end Is_Numeric_Test;
|
||||
|
|
@ -2,5 +2,6 @@ print numeric? "hello world"
|
|||
print numeric? "1234"
|
||||
print numeric? "1234 hello world"
|
||||
print numeric? "12.34"
|
||||
print numeric? "0x2bf"
|
||||
print numeric? "!#@$"
|
||||
print numeric? "-1.23"
|
||||
print numeric? "-15"
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
program-id. is-numeric.
|
||||
procedure division.
|
||||
display function test-numval-f("abc") end-display
|
||||
display function test-numval-f("-123.01E+3") end-display
|
||||
if function test-numval-f("+123.123") equal zero then
|
||||
display "is numeric" end-display
|
||||
else
|
||||
display "failed numval-f test" end-display
|
||||
end-if
|
||||
goback.
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. Is-Numeric.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 Numeric-Chars PIC X(10) VALUE "0123456789".
|
||||
|
||||
01 Success CONSTANT 0.
|
||||
01 Failure CONSTANT 128.
|
||||
|
||||
LOCAL-STORAGE SECTION.
|
||||
01 I PIC 99.
|
||||
|
||||
01 Num-Decimal-Points PIC 99.
|
||||
01 Num-Valid-Chars PIC 99.
|
||||
|
||||
LINKAGE SECTION.
|
||||
01 Str PIC X(30).
|
||||
|
||||
PROCEDURE DIVISION USING Str.
|
||||
IF Str = SPACES
|
||||
MOVE Failure TO Return-Code
|
||||
GOBACK
|
||||
END-IF
|
||||
|
||||
MOVE FUNCTION TRIM(Str) TO Str
|
||||
|
||||
INSPECT Str TALLYING Num-Decimal-Points FOR ALL "."
|
||||
IF Num-Decimal-Points > 1
|
||||
MOVE Failure TO Return-Code
|
||||
GOBACK
|
||||
ELSE
|
||||
ADD Num-Decimal-Points TO Num-Valid-Chars
|
||||
END-IF
|
||||
|
||||
IF Str (1:1) = "-" OR "+"
|
||||
ADD 1 TO Num-Valid-Chars
|
||||
END-IF
|
||||
|
||||
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 10
|
||||
INSPECT Str TALLYING Num-Valid-Chars
|
||||
FOR ALL Numeric-Chars (I:1) BEFORE SPACE
|
||||
END-PERFORM
|
||||
|
||||
INSPECT Str TALLYING Num-Valid-Chars FOR TRAILING SPACES
|
||||
|
||||
IF Num-Valid-Chars = FUNCTION LENGTH(Str)
|
||||
MOVE Success TO Return-Code
|
||||
ELSE
|
||||
MOVE Failure TO Return-Code
|
||||
END-IF
|
||||
|
||||
GOBACK
|
||||
.
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
(defun string-valid-number-p (str)
|
||||
"Test if STR is a numeric string.
|
||||
Eliminate strings with commas in them because ELisp numbers do
|
||||
not contain commas. Then check if remaining strings would be
|
||||
valid ELisp numbers if the quotation marks were removed."
|
||||
(and
|
||||
;; no comma in string, because ELisp numbers do not have commas
|
||||
;; we need to eliminate any string with a comma, because the
|
||||
;; numberp function below will not weed out commas
|
||||
(not (string-match-p "," str))
|
||||
;; no errors from numberp function testing if a number
|
||||
(ignore-errors (numberp (read str)))))
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
(setq valid-strings '("3" "0" "-0" "2." "1000" "-4" "-5." "6.2" "-8.45" "+15e2" "-15e2" "#b101100" "#o54" "#x2c" "1500.0" "#24r1k" "3"))
|
||||
|
||||
(setq invalid-strings '("3cat" "1,000" "5.6.7" "cat3" "def" "zero"))
|
||||
|
||||
(with-current-buffer (pop-to-buffer "my-test")
|
||||
(erase-buffer)
|
||||
(insert "Test for valid strings:\n")
|
||||
(dolist (test-string valid-strings)
|
||||
(let ((test-result))
|
||||
(setq test-result (string-valid-number-p test-string))
|
||||
(insert (format "%-8s - %s \n" test-string test-result))))
|
||||
(insert "\n" "\n")
|
||||
(insert "Test for invalid strings:\n")
|
||||
(dolist (test-string invalid-strings)
|
||||
(let ((test-result))
|
||||
(setq test-result (string-valid-number-p test-string))
|
||||
(insert (format "%-5s - %s \n" test-string test-result)))))
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
include get.e
|
||||
|
||||
function is_numeric(sequence s)
|
||||
sequence val
|
||||
val = value(s)
|
||||
return val[1]=GET_SUCCESS and atom(val[2])
|
||||
end function
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
static function isNumeric(n:String):Bool
|
||||
{
|
||||
if (Std.parseInt(n) != null) //Std.parseInt converts a string to an int
|
||||
{
|
||||
return true; //as long as it results in an integer, the function will return true
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
function isNumeric ($x) {
|
||||
try {
|
||||
0 + $x | Out-Null
|
||||
return $true
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
function isNumeric ($x) {
|
||||
$x2 = 0
|
||||
$isNum = [System.Int32]::TryParse($x, [ref]$x2)
|
||||
return $isNum
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
REBOL [
|
||||
Title: "Is Numeric?"
|
||||
URL: http://rosettacode.org/wiki/IsNumeric
|
||||
]
|
||||
|
||||
; Built-in.
|
||||
|
||||
numeric?: func [x][not error? try [to-decimal x]]
|
||||
|
||||
; Parse dialect for numbers.
|
||||
|
||||
sign: [0 1 "-"]
|
||||
digit: charset "0123456789"
|
||||
int: [some digit]
|
||||
float: [int "." int]
|
||||
number: [
|
||||
sign float ["e" | "E"] sign int |
|
||||
sign int ["e" | "E"] sign int |
|
||||
sign float |
|
||||
sign int
|
||||
]
|
||||
|
||||
pnumeric?: func [x][parse x number]
|
||||
|
||||
; Test cases.
|
||||
|
||||
cases: parse {
|
||||
10 -99
|
||||
10.43 -12.04
|
||||
1e99 1.0e10 -10e3 -9.12e7 2e-4 -3.4E-5
|
||||
3phase Garkenhammer e n3v3r phase3
|
||||
} none
|
||||
foreach x cases [print [x numeric? x pnumeric? x]]
|
||||
|
|
@ -1 +0,0 @@
|
|||
IsNumeric(Expr)
|
||||
Loading…
Add table
Add a link
Reference in a new issue