2016-05-13 02:26:52 +00:00
|
|
|
module Bob exposing (..)
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
import String
|
|
|
|
import Regex
|
|
|
|
|
|
|
|
|
|
|
|
hey : String -> String
|
|
|
|
hey remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
if isShouting remark then
|
|
|
|
"Whoa, chill out!"
|
|
|
|
else if isQuestion remark then
|
|
|
|
"Sure."
|
|
|
|
else if isSilence remark then
|
|
|
|
"Fine. Be that way!"
|
|
|
|
else
|
|
|
|
"Whatever."
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
isShouting : String -> Bool
|
|
|
|
isShouting remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
isUppercase remark && hasCharacters remark
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
isUppercase : String -> Bool
|
|
|
|
isUppercase remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
remark == String.toUpper remark
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
isQuestion : String -> Bool
|
|
|
|
isQuestion remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
String.endsWith "?" remark
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
hasCharacters : String -> Bool
|
|
|
|
hasCharacters remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
Regex.contains characterRegex remark
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
characterRegex : Regex.Regex
|
|
|
|
characterRegex =
|
2016-06-19 21:46:13 +00:00
|
|
|
Regex.regex "[a-zA-Z]"
|
2016-02-27 17:45:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
isSilence : String -> Bool
|
|
|
|
isSilence remark =
|
2016-06-19 21:46:13 +00:00
|
|
|
String.isEmpty (String.trim remark)
|