bob.scm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(define-module (bob)
  #:export (response-for))

(use-modules (srfi srfi-1))

(define (blank-space? char-list) 
  (and-map (lambda (x) (char-whitespace? x)) char-list))

(define (response-for query)
  (let ((string-list (string->list query)))
    (let ((alpha-characters (filter char-alphabetic? string-list)))
      (cond
        [(blank-space? string-list) "Fine. Be that way!"]
        [(and (not (eq? alpha-characters '()))
              (and-map char-upper-case? alpha-characters)) "Whoa, chill out!"]
        [(and (not (eq? string-list '()))
              (eq? #\? (last string-list))) "Sure."]
        [else "Whatever."]
        )
      ) 
    )
  )

Comments


You're not logged in right now. Please login via GitHub to comment