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

From: Marco Morazan (morazanm at gmail.com)
Date: Sun May 10 08:32:42 EDT 2009

On Sun, May 10, 2009 at 8:04 AM, Grant Rettke <grettke at acm.org> wrote:
> Is this definition of word OK?
> ;; A word is a list of 0 or more symbols ('a, 'b, ..., 'z).

Yes, it is correct.

I point out, however, that the abbreviation you are using (i.e. the
Kleene star) hides the structure of a word. If you state that a word
is either

1. an empty list or
2. (cons s w), where s is a symbol and w is a word

then the structure of any function on words jumps out at you. There
are two types of words. Therefore, you need a conditional statement
with two cond-lines. A word of type 2 contains a selfreference.
Therefore, the w must be processed recursively.




Posted on the users mailing list.