Another Exercise From HTDP
Another exercise from Chapter 1 of How to Design Programs.
My answer for exercise 9 in Chapter 1.
A few more points lest I forget:
-
It’s very handy to format your racket code. Simply use raco to install the fmt package (
raco pkg install fmt
). Once you do that the command line is something like:raco fmt --width #your_preferred_maxwidth --indent #your_preferred_indentation -i #racket_source_file
. In my case it’s thisraco fmt --width 80 --indent 3 -i htdp_chapter1_ex9.rkt
. -
Make sure if you do anything in DrRacket that you save your definitions as text. Otherwise the formatter won’t be able to do a thing with the source. Saving as text is under the
Save Other
menu in DrRacket.