SEDOLs: Difference between revisions
m
→{{header|Haskell}}
(→{{header|Haskell}}: Added test case and output for ill-formed sedol string.) |
|||
Line 1,636:
checkSum x =
case traverse sedolValue x of
Right xs -> (show . checkSumFromSedolValues) xs
Left annotated -> annotated
checkSumFromSedolValues :: [Int] ->
checkSumFromSedolValues xs =
[1, 3,
sedolValue :: Char -> Either String Int
Line 1,660 ⟶ 1,659:
| isDigit c = Right (ord c - ord '0')
| isAsciiUpper c = Right (ord c - ord 'A' + 10)
--------------------------- TEST -------------------------
|