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

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun May 10 16:25:48 EDT 2009

Carl is right. Period. -- Matthias



On May 10, 2009, at 10:47 AM, Henk Boom wrote:

> 2009/5/10 Grant Rettke <grettke at acm.org>:
>> 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)))
>
> (check-expect (word? (list 'not 'a 'word)) false)
>
>     Henk
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.