Sha256: 73d5b7c991781a309920286e92cc83df11d97e7a0075847e664243745e353f8a

Contents?: true

Size: 885 Bytes

Versions: 218

Compression:

Stored size: 885 Bytes

Contents

module Bob
  ( hey
  ) where

import Prelude
import Data.String as String
import Data.Either as Either
import Data.String.Regex as Regex
import Data.String.Regex.Flags (noFlags)
import Partial.Unsafe as Partial

hey :: String -> String
hey msg =
  if hasLetters msg && allUppercase msg then
    "Whoachill out!"
  else if isQuestion msg then
    "Sure."
  else if isSilence msg then
    "Fine. Be that way!"
  else
    "Whatever."


allUppercase :: String -> Boolean
allUppercase str =
  String.toUpper str == str


isQuestion :: String -> Boolean
isQuestion =
  testRegex "\\?$"


hasLetters :: String -> Boolean
hasLetters =
  testRegex "[a-zA-Z]"


isSilence :: String -> Boolean
isSilence =
  testRegex "^[\\s\\t\\n]*$"


testRegex :: String -> String -> Boolean
testRegex patternStr =
  Regex.test
  $ Partial.unsafePartial
  $ Either.fromRight
  $ Regex.regex patternStr noFlags

Version data entries

218 entries across 218 versions & 1 rubygems

Version Path
trackler-2.2.1.37 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.36 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.35 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.34 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.33 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.32 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.31 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.30 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.29 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.28 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.27 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.26 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.25 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.24 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.23 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.22 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.21 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.20 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.19 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.18 tracks/purescript/exercises/bob/examples/src/Bob.purs