[plt-scheme] 12.4.2 word definition; is this OK?

From: Grant Rettke (grettke at acm.org)
Date: Sun May 10 08:04:08 EDT 2009

Is this definition of word OK?

;; A word is a list of 0 or more symbols ('a, 'b, ..., 'z).

(check-expect empty (list))

;; word? : word -> boolean
;; to determine whether the argument is a word
(define (word? arg)
  (cond ((empty? arg) true)
        ((symbol? (first arg)) (word? (rest arg)))
        (else false)))

; word? unit tests

(check-expect true
              (word? (list)))
(check-expect true
              (word? (list 'a)))
(check-expect true
              (word? (list 'a 'b)))
(check-expect true
              (word? (list 'a 'b 'c)))
(check-expect false
              (word? (list 'a 'b (list))))
(check-expect false
              (word? (list (list) 'b 'c)))

Posted on the users mailing list.