[racket] HtDP data definitions in Scribble
On Jan 26, 2014, at 9:02 PM, Marco Morazan <morazanm at gmail.com> wrote:
> Dear All,
>
> Is there an easy (as in first-year students can do it) way nicely render data definitions a la HtDP using Scribble?
>
> For instance,
>
> A word is a (listof symbol).
>
> @defproc[(correct-spelling [w word?]) word]{Returns a word.}
>
> Having word? and word refer to its data definition.
>
I use this source format for HtDP/2e:
@(begin
#reader scribble/comment-reader
(racketblock
;; A @deftech{List-of-amounts} is one of:
;; -- @racket[empty]
;; -- @racket[(cons #, @tech{PositiveNumber} #, @tech{List-of-amounts})]
;; interp. a @tech{List-of-amounts} represents some amounts of money
))
(1) it really is Racket/*SL code/comments
(2) 'deftech' is used to introduce the defined set (class) of data
(3) tech is used to reference it both in the definition itself and outside
[I have some primitive emacs keystroke that do some of this work for me.]
Would I do this to freshmen? No. -- Matthias