· 5 years ago · Jul 25, 2020, 10:38 PM
1module Main where
2
3import Data.String.Utils
4
5main :: IO ()
6main =
7 print [
8 check_googler_by email | email <- [ "adam@gmail.com",
9 "boob@yahoo.com",
10 "test@gmail.com" ]]
11
12ends_with :: String -> String -> Bool
13ends_with str suffix = suffix `endswith` str
14
15check_googler_by :: String -> String
16check_googler_by email =
17 if email `ends_with` "gmail.com"
18 then name_from email ++ " is a Googler"
19 else email
20 where name_from = \full_email -> takeWhile (/= '@') full_email