CUSIP: Difference between revisions

3 bytes removed ,  1 month ago
 
(3 intermediate revisions by 2 users not shown)
Line 55:
<syntaxhighlight lang=11l>F cusip_check(=cusip)
I cusip.len != 9
X.throw ValueError(‘CUSIP must be 9 characters’)
 
cusip = cusip.uppercase()
Line 2,988:
=={{header|langur}}==
If we don't strictly follow the pseudo-code, we can do this.
<syntaxhighlight lang=langur>val .isCusip = ffn(.s) {
if not isString(.s) is not string or len(.s) != 9 {
return false
}
 
val .basechars = cp2s('0'..'9') ~ cp2s('A'..'Z') ~ "*@#"
 
val .sum = for[=0] .i of 8 {
Line 2,999:
if not .v: return false
.v = .v[1]-1
if .i div 2: .v x*= 2
_for += .v \ 10 + .v rem 10
}
Line 3,006:
}
 
val .candidates = wfw/037833100 17275R102 38259P508 594918104 68389X106 68389X105/
 
for .c in .candidates {
Line 3,014:
Following the pseudo-code would look more like the following.
{{trans|Go}}
<syntaxhighlight lang=langur>val .isCusip = ffn(.s) {
if not isString(.s) is not string or len(.s) != 9 {
return false
}
Line 3,037:
}
 
if .i div 2: .v x*= 2
_for += .v \ 10 + .v rem 10
}
890

edits