SEDOLs: Difference between revisions

87 bytes removed ,  18 days ago
m
(→‎{{header|Kotlin}}: Make Kotlin solution more succinct using modern library features)
(3 intermediate revisions by 2 users not shown)
Line 2,373:
 
fun sedol7(sedol6: String): String {
if require(sedol6.length !== 6) { "Length of argument string must be 6" }
require(sedol6.all { it in throwvalidChars }) { IllegalArgumentException("Argument string contains an invalid character") }
throw IllegalArgumentException("Length of argument string must be 6")
if (sedol6.any { it !in validChars })
throw IllegalArgumentException("Argument string contains an invalid character")
 
val sum = sedol6.map { it.digitToInt(36) }.zip(weights, Int::times).sum()
Line 2,410 ⟶ 2,408:
=={{header|langur}}==
{{trans|Go}}
<syntaxhighlight lang="langur">val .csd = ffn(.code) {
switch len(.code) {
case 0:
Line 2,426 ⟶ 2,424:
val .nums = s2n .code
val .sum = for[=0] .i of .nums {
_for += .nums[.i] x* .weight[.i]
}
 
Line 2,432 ⟶ 2,430:
}
 
val .h = h{
# invalid...
"": 0,
Line 3,206 ⟶ 3,204:
sedol, sedolweight)
)
return str((10 - (tmp % 10)) % 10)
 
for sedol in '''
Line 3,250 ⟶ 3,248:
Right(0)
)
)(lambda d: Right(str((10 - (d % 10)) % 10)))
 
 
885

edits