ABC words: Difference between revisions

Content added Content deleted
(Updated Haskell version)
Line 1,582: Line 1,582:


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


Line 1,592: Line 1,592:
residue 'a' "bc" s
residue 'a' "bc" s
>>= residue 'b' "c"
>>= residue 'b' "c"
>>= (bool Nothing . Just) <*> ('c' `elem`)
>>= elemIndex 'c'


residue :: Char -> String -> String -> Maybe String
residue :: Char -> String -> String -> Maybe String