Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,22 @@
CREATE OR REPLACE FUNCTION is_valid_number(s) AS
CASE
WHEN s IS NULL THEN false
WHEN try_cast(s AS DOUBLE) IS NOT NULL THEN true
ELSE false
END;
# Illustration
select s, is_valid_number(s) from
(select unnest([
'123.0',
'123.',
'-123',
'3.14159',
'1.2.3',
'abc',
'A440',
' 12 ',
'0A',
'+1E10',
'1E-10'
]) as s);

View file

@ -0,0 +1,67 @@
#*
GRAMMAR OR PARSE TOKENS
int* - an unsigned integer
sint* - a +/- signed integer
.* - decimal point
HISTORY
12 sept 2021: written, working
*#
# remove leading space
begin { while [:space:]; clear; }
read;
[0-9] {
while [0-9]; put; clear; add "int*"; push; .reparse
}
[.+-] { put; add "*"; push; .reparse }
[:space:] { while [:space:]; clear; add "space*"; push; .reparse }
!"" {
put; clear;
add "Non-numeric char at "; lines; add ":"; chars; add "\n";
print; quit;
}
parse>
# To visualise token reduction uncomment this:
#lines; add ":"; chars; add " "; print; clear;
#add "\n"; unstack; print; clip; stack;
pop; pop;
# -------------
# 2 tokens
"+*int*","-*int*" { clear; add "sint*"; push; .reparse }
pop;
# -------------
# 3 tokens
"sint*.*int*","int*.*int*" {
clear; add "float*"; push; .reparse
}
(eof) {
# ignore trailing space
stack; pop; "space*" { clear; }
unstack;
"int*","sint*","float*" {
replace "sint*" "signed integer,";
replace "int*" "integer,";
replace "*" ",";
put; clear;
add "It looks like a number (of type "; get; add ")\n";
print; quit;
}
replace "sint*" "signed integer,";
replace "int*" "integer,";
replace "*" ",";
put; clear;
add "Doesnt look like one number \n";
add "It was parsed as '"; get; add "'\n";
print; quit;
}
push; push; push;

View file

@ -0,0 +1,9 @@
function chk(a)
return tonumber(a) != nil
end
a = {"123", "-320",
"-1342.40", "abc",
"1,234", "a123.0"}
a:map(chk); print(a:unpack())

View file

@ -0,0 +1,3 @@
proc isNumeric {str} {
string is double -strict $str
}

View file

@ -0,0 +1,17 @@
# will output an error message
# and quit
proc fatal {msg} {
puts stderr "$msg"
exit 1
}
# a bad string
set x 174gg.4
try {
set n [expr {double($x)}]
set n [expr {int($x)}]
puts $x
} on error { error options } {
fatal "$::errorInfo"
}

View file

@ -1 +0,0 @@
proc isNumeric str {string is double -strict $str}