Matches.hs (301B)

1 2 module Matches where 3 4 import Control.Monad 5 6 appears :: Eq a => [a] -> [a] -> Int 7 appears = go where 8 go [] _ = 1 9 go _ [] = 0 10 go ab@(b:bs) (c:cs) 11 | b == c = appears bs cs + appears ab cs 12 | otherwise = appears ab cs 13 14 appears' n = length . filter (== n) . filterM (const [True, False]) 15