Data update
This commit is contained in:
parent
29a5eea0d4
commit
5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions
|
|
@ -0,0 +1,12 @@
|
|||
(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)))))
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
(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)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue