CUSIP: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: allMaybe is just sequence) |
|||
Line 1,414: | Line 1,414: | ||
data Result = Valid | BadCheck | TooLong | TooShort | InvalidContent deriving Show |
data Result = Valid | BadCheck | TooLong | TooShort | InvalidContent deriving Show |
||
prependMaybe :: Maybe a -> Maybe [a] -> Maybe [a] |
|||
prependMaybe (Just v) (Just vs) = Just (v:vs) |
|||
prependMaybe _ _ = Nothing |
|||
-- convert a list of Maybe to a Maybe list. |
-- convert a list of Maybe to a Maybe list. |
||
-- result is Nothing if any of values from the original list are Nothing |
-- result is Nothing if any of values from the original list are Nothing |
||
allMaybe :: [Maybe a] -> Maybe [a] |
allMaybe :: [Maybe a] -> Maybe [a] |
||
allMaybe = |
allMaybe = sequence |
||
toValue :: Char -> Maybe Int |
toValue :: Char -> Maybe Int |