[racket] Working through "How to Design Programs"

From: benmarkwell at gmail.com (benmarkwell at gmail.com)
Date: Fri Jul 29 16:55:20 EDT 2011

I am currently working on Structure Definitions and am hoping that I can get
some feedback through this mailing list on whether I am doing things
correctly or not.

*Exercise 6.4.3.*   Provide a structure definition and a data definition for
representing three-letter words. A word consists of letters, which we
represent with the symbols 'a through 'z.

Here is what I have come up with.

;; word : symbol -> symbol
;  produce a word with the letters it's made of.
;  word is a structure
;  (make-word first-letter second-letter third-letter)
;  where first-letter, second-letter, and third-letter are symbols 'a thru
z'

(define-struct word (first-letter second-letter third-letter))
(define cat (make-word 'c 'a 't))

Using the interactive prompt I can do the following:
> (word-first-letter cat)
'c
> (word-third-letter cat)
't
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110729/25a402de/attachment.html>

Posted on the users mailing list.