CUSIP: Difference between revisions
→{{header|langur}}
(→{{header|Modula-2}}: Added MiniScript) |
Langurmonkey (talk | contribs) |
||
(5 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 = f(.s) {
▲ if not isString(.s) or len(.s) != 9 {
return false
}
val
val
var
if not
if
_for +=
}
}
val
for
writeln
}
Following the pseudo-code would look more like the following.
{{trans|Go}}
<syntaxhighlight lang=langur>val
if s is not
return false
}
val
val .c = .s[.i]▼
var .v = 0▼
val sum = for[=0]
switch[and] c {
case >= '0', <= '9':
case >= 'A', <= 'Z':
case '*':
case '@':
case '#':
default: return false
}
if
_for +=
}
}
val
for
writeln
}
{{out}}
|