module Bob open System let containsLowercase = Seq.fold (fun a x -> if x >= 'a' && x <= 'z' then true else a) false let containsUppercase = Seq.fold (fun a x -> if x >= 'A' && x <= 'Z' then true else a) false let containsLetters input = containsLowercase input || containsUppercase input let lastLetter = Seq.last let question (input: string) = String.length input > 0 && lastLetter input = '?' let upperCase (input: string) = not (containsLowercase input) && containsUppercase input let emptyOrBlank (input: string) = String.length input = 0 let response (rawInput: string): string = let strip = ['\t';' ';'\n';'\r'] let input = rawInput |> Seq.filter (fun c -> not (List.contains c strip)) |> String.Concat let uc = upperCase input let q = question input let empty = emptyOrBlank input if q && uc then "Calm down, I know what I'm doing!" else if q then "Sure." else if empty then "Fine. Be that way!" else if uc then "Whoa, chill out!" else "Whatever."