CUSIP: Difference between revisions
→{{header|langur}}
Langurmonkey (talk | contribs) |
Langurmonkey (talk | contribs) |
||
(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 =
if
return false
}
val .basechars =
val .sum = for[=0] .i of 8 {
Line 2,999:
if not .v: return false
.v = .v[1]-1
if .i div 2: .v
_for += .v \ 10 + .v rem 10
}
Line 3,006:
}
val .candidates =
for .c in .candidates {
Line 3,014:
Following the pseudo-code would look more like the following.
{{trans|Go}}
<syntaxhighlight lang=langur>val .isCusip =
if
return false
}
Line 3,037:
}
if .i div 2: .v
_for += .v \ 10 + .v rem 10
}
|