[racket] HtDP data definitions in Scribble

19 views
Skip to first unread message

Marco Morazan

unread,
Jan 26, 2014, 9:02:16 PM1/26/14
to PLT-Scheme Mailing List
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.

--

Cheers,

Marco

Have a´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´ (¸.·´ * wonderful day! :)

Matthias Felleisen

unread,
Jan 27, 2014, 5:34:28 PM1/27/14
to Marco Morazan, PLT-Scheme Mailing List

On Jan 26, 2014, at 9:02 PM, Marco Morazan <mora...@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




____________________
Racket Users list:
http://lists.racket-lang.org/users
Reply all
Reply to author
Forward
0 new messages