Sha256: 405564df8e8549164e4fa0996bf6c52345cb09e2bf4eebc4100a9988dbd64d01

Contents?: true

Size: 672 Bytes

Versions: 396

Compression:

Stored size: 672 Bytes

Contents

(defmodule bob
  (export (response-for 1)))

(defun response-for (str)
  (first-match
    str
    `(#(,#'all-spaces?/1    "Fine. Be that way!")
      #(,#'shouting?/1      "Whoa, chill out!")
      #(,#'question?/1      "Sure.")
      #(,(lambda (_) 'true) "Whatever."))))

(defun first-match
  ([s (cons `#(,f ,res) fs)]
   (case (funcall f s)
     ('true res)
     ('false (first-match s fs)))))

(defun all-spaces? (str) (=/= (re:run str "^(\\h|\\v)*$" '(unicode)) 'nomatch))

(defun shouting? (str)
  (andalso (lists:any (lambda (c) (andalso (>= c #\A) (=< c #\Z))) str)
           (=:= (string:to_upper str) str)))

(defun question? (str) (=:= (lists:last str) #\?))

Version data entries

396 entries across 396 versions & 1 rubygems

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