Jump to content

SEDOLs: Difference between revisions

28 bytes removed ,  3 years ago
m
(→‎{{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] -> StringInt
checkSumFromSedolValues xs =
show $rem
rem( 10
( 10 - rem
-( remsum $
( sum $zipWith
zipWith(*)
[1, 3, (*)1, 7, 3, 9]
[1, 3, 1, 7, 3, 9]xs
xs)
)10
10)
)10
10
 
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 -------------------------
9,655

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.