Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -1,26 +1,26 @@
val .csd = fn(.code) {
switch len(.code) {
val csd = fn(code) {
switch len(code) {
case 0:
return "nada, zip, zilch"
case != 6:
return "invalid length"
}
if .code -> re/[^B-DF-HJ-NP-TV-Z0-9]/ {
if code -> re/[^B-DF-HJ-NP-TV-Z0-9]/ {
return "invalid character(s)"
}
val .weight = [1,3,1,7,3,9]
val weight = [1,3,1,7,3,9]
val .nums = s2n .code
val .sum = for[=0] .i of .nums {
_for += .nums[.i] * .weight[.i]
val nums = s2n(code)
val sum = for[=0] i of nums {
_for += nums[i] * weight[i]
}
string 9 - (.sum - 1) rem 10
string 9 - (sum - 1) rem 10
}
val .h = h{
val h = {
# invalid...
"": 0,
"123": 0,
@ -45,14 +45,14 @@ val .h = h{
"B00030": 0,
}
for .input in sort(keys .h) {
val .d = .csd(.input)
if len(.d) > 1 {
writeln .input, ": ", .d
for input in sort(keys(h)) {
val d = csd(input)
if len(d) > 1 {
writeln input, ": ", d
} else {
val .expect = string .h[.input]
write .input, .d
writeln if .expect == .d {""} else {
$" (SEDOL test failed; expected check digit \.expect;)"}
val expect = h[input] -> string
write input, d
writeln if expect == d {""} else {
" (SEDOL test failed; expected check digit {{expect}})"}
}
}