Validate International Securities Identification Number: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: used quotRem in lieu of divMod) |
m (→{{header|Haskell}}: (combined some type signatures)) |
||
Line 923: | Line 923: | ||
import Data.Maybe (fromMaybe) |
import Data.Maybe (fromMaybe) |
||
isinValid :: String -> Bool |
isinValid, isinPattern, luhn :: String -> Bool |
||
isinValid isin = isinPattern isin && luhn (asNumericString isin) |
isinValid isin = isinPattern isin && luhn (asNumericString isin) |
||
isinPattern :: String -> Bool |
|||
isinPattern isin = |
isinPattern isin = |
||
(length isin == 12) && |
(length isin == 12) && |
||
Line 933: | Line 932: | ||
elem (last isin) digits |
elem (last isin) digits |
||
luhn :: String -> Bool |
|||
luhn = |
luhn = |
||
(0 ==) . |
(0 ==) . |
||
(` |
(`rem` 10) . |
||
sum . |
sum . |
||
fmap (uncurry (+) . (`quotRem` 10)) . |
fmap (uncurry (+) . (`quotRem` 10)) . |