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.17 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.16 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.15 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.14 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.13 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.12 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.11 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.10 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.9 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.8 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.7 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.6 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.5 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.4 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.3 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.2 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.1 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.1.0 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.0.6 tracks/purescript/exercises/bob/examples/src/Bob.purs
trackler-2.2.0.5 tracks/purescript/exercises/bob/examples/src/Bob.purs