SEDOLs: Difference between revisions

26 bytes removed ,  18 days ago
 
Line 2,408:
=={{header|langur}}==
{{trans|Go}}
<syntaxhighlight lang="langur">val .csd = fn(.code) {
val csd = switch lenfn(.code) {
switch len(code) {
case 0:
return "nada, zip, zilch"
Line 2,416 ⟶ 2,417:
}
 
if .code -> re/[^B-DF-HJ-NP-TV-Z0-9]/ {
return "invalid character(s)"
}
 
val .weight = [1,3,1,7,3,9]
 
val .nums = s2n .(code)
val .sum = for[=0] .i of .nums {
_for += .nums[.i] * .weight[.i]
}
 
string 9 - (.sum - 1) rem 10
}
 
val .h = {
# invalid...
"": 0,
Line 2,455 ⟶ 2,456:
}
 
for .input in sort(keys .(h)) {
val .d = .csd(.input)
if len(.d) > 1 {
writeln .input, ": ", .d
} else {
val .expect = string .h[.input] -> string
write .input, .d
writeln if .expect == .d {""} else {
" (SEDOL test failed; expected check digit {{.expect}})"}
}
}
1,007

edits