Anonymous user
IBAN: Difference between revisions
→{{header|Haskell}}
(Added FreeBASIC) |
|||
Line 1,517:
This program uses the Maybe and Either monads to handle failures. Values of type 'Maybe a' can contain 'Nothing' (no value) or 'Just a' (a value of type 'a'). Values of type 'Either a b' contain 'Left b' (usually indicating failure) or 'Right c' (usually indicating success).
<lang Haskell>import Data.Char (toUpper)
import Data.Maybe (fromJust)
validateIBAN :: String -> Either String String
Line 1,556 ⟶ 1,557:
-- convert the result to an integer
p4 :: Integer
p4 = read $ concat $
▲ | otherwise = let (Just ys) = lookup x replDigits
-- see if the number is valid
check = if sane
|