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.0.6.39 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.38 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.37 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.36 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.35 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.34 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.33 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.32 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.31 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.30 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.29 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.28 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.27 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.26 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.25 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.24 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.23 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.22 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.21 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.6.20 tracks/purescript/exercises/bob/examples/src/Bob.purs