ABC words: Difference between revisions

Content added Content deleted
(→‎{{header|Diego}}: Added Diego entry)
(Updated Haskell version)
Line 1,582: Line 1,582:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang haskell>import Data.Maybe (isJust)
<lang haskell>import Data.Bool (bool)
import Data.Maybe (isJust)


------------------------ ABC WORDS -----------------------
------------------------ ABC WORDS -----------------------
Line 1,589: Line 1,590:
isABC s =
isABC s =
isJust $
isJust $
afterChar 'a' "bc" s
residue 'a' "bc" s
>>= afterChar 'b' "c"
>>= residue 'b' "c"
>>= afterChar 'c' ""
>>= (bool Nothing . Just) <*> ('c' `elem`)


afterChar :: Char -> String -> String -> Maybe String
residue :: Char -> String -> String -> Maybe String
afterChar c except = go
residue c except = go
where
where
go [] = Nothing
go [] = Nothing