Created
January 29, 2020 00:51
-
-
Save heath/527aca0963f3484deb29a13c2a693ca1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
-- Challenge: rudimentary spam filter | |
-- given the sample blacklist and comments check to see if | |
-- the phrases in the blacklist are in the comment | |
import Data.List (isInfixOf) | |
type BlackList = [String] | |
type Comment = String | |
comment1 :: Comment | |
comment1 = "Collection of my foo bar" | |
comment2 :: Comment | |
comment2 = "How to get free hotel upgrades" | |
blackList :: BlackList | |
blackList = | |
[ | |
"foo bar", | |
"baz qux quux", | |
"spam", | |
"grault garply i", | |
"grault garply ii" | |
] | |
inBlackList :: Comment -> BlackList -> Bool | |
inBlackList comment blacklist = | |
any (\phrase -> isInfixOf phrase comment) blacklist | |
main = | |
$ show | |
$ inBlackList comment1 blacklist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment