[plt-scheme] HtDP Exercise 12.4.2 - To the authors of HtDP

From: artificial (4rt.f15h at gmail.com)
Date: Tue Dec 1 10:52:27 EST 2009

Hello

Since I got interested in functional programming, I did a little
research in the web, downloaded DrScheme and started to work through
HtDP a few days ago. I know imperative languages (mostly C, Java,
Ruby) fairly well, so I skimmed through the book, yet did all the
exercises that contained writing scheme code.

Then I encountered exercise 12.4.2. I read it, started to code and
failed terribly. I couldn't get it right and got frustrated.

So I fired up chrome and googled for a solution, but I couldn't find
one. Just a few threads on this mailing list which didn't provide a
solution but emphasized the usage of "design recipes". I googled some
more for permutations, learned a little about the math background -
which was interesting but didn't help me to solve 12.4.2, and found
video lectures of Jerry Cain of Stanford which contained a spectacular
permutation function but in the end didn't help me either.

In the end, I started over with HtDP and learned every little bit
about "design recipes". Then I took pen and paper and designed the
arrangements function using what I have learned. After that I fired up
DrScheme, entered the 4 functions (including the given function
arrangements) and check-expects with the examples for each function I
came up with, and guess what? It worked right away :-D (this was a few
minutes ago).

Thank you very much. I think learned my lesson.

PS: I'm not an English speaker, but I hope my writing makes sense
enough for you to understand.


Posted on the users mailing list.