Sha256: adb59492cc51e6464085a51cd219ec18f9b40481f72e9d64bdf81a48805930fe

Contents?: true

Size: 918 Bytes

Versions: 66

Compression:

Stored size: 918 Bytes

Contents

module Bob exposing (hey)

import Regex
import String


hey : String -> String
hey remark =
    if isShouting remark && isQuestion remark then
        "Calm down, I know what I'm doing!"
    else if isShouting remark then
        "Whoa, chill out!"
    else if isQuestion remark then
        "Sure."
    else if isSilence remark then
        "Fine. Be that way!"
    else
        "Whatever."


isShouting : String -> Bool
isShouting remark =
    isUppercase remark && hasCharacters remark


isUppercase : String -> Bool
isUppercase remark =
    remark == String.toUpper remark


isQuestion : String -> Bool
isQuestion remark =
    String.endsWith "?" remark


hasCharacters : String -> Bool
hasCharacters remark =
    Regex.contains characterRegex remark


characterRegex : Regex.Regex
characterRegex =
    Regex.regex "[a-zA-Z]"


isSilence : String -> Bool
isSilence remark =
    String.isEmpty (String.trim remark)

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.179 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.178 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.177 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.176 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.175 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.174 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.173 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.172 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.171 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.170 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.169 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.167 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.166 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.165 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.164 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.163 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.162 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.161 tracks/elm/exercises/bob/Bob.example.elm
trackler-2.2.1.160 tracks/elm/exercises/bob/Bob.example.elm