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.8.55 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.54 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.53 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.52 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.51 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.50 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.49 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.48 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.47 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.46 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.45 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.44 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.43 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.42 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.41 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.40 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.39 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.38 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.37 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.0.8.36 tracks/purescript/exercises/bob/examples/src/Bob.purs