Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
7
Task/SEDOLs/Scala/sedols.scala
Normal file
7
Task/SEDOLs/Scala/sedols.scala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class SEDOL(s: String) {
|
||||
require(s.size == 6 || s.size == 7, "SEDOL length must be 6 or 7 characters")
|
||||
require(s.size == 6 || s(6).asDigit == chksum, "Incorrect SEDOL checksum")
|
||||
require(s forall (c => !("aeiou" contains c.toLower)), "Vowels not allowed in SEDOL")
|
||||
def chksum = 10 - ((s zip List(1, 3, 1, 7, 3, 9) map { case (c, w) => c.asDigit * w } sum) % 10)
|
||||
override def toString = s.take(6) + chksum
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue