[plt-scheme] Re: Permutations (newbie)
Matthias Felleisen <matthias at ...> writes:
> 1. Please don't post solutions to these problems on the newsgroup.
I'm sorry, I didn't know the book was off-limits on the newsgroup. My solution
doesn't quite adhere to the templates provided in the book, so the damage should
be limited - it's bound not to be the only public permutation implementation out
there.
> 2. Follow the design recipe. You're obviously not and that explains
> your struggle.
> For example, a test is not
>
> (f 10) ;; test
Are the recipes provided in the book actual standard Scheme idiom? I interpreted
them as just one way of approaching programming. My "; test" comment was there
just a reminder to myself and I didn't intend to post that entire line.
> or even better
>
> (equal? (f 10) 20)
That is how I tend to test my Scheme snippets, usually with a couple of them
bunched together in an (and) to get a single failure/success result. It serves
my purposes at this point.
> 3. HtDP does not teach you Scheme (just a bit) but it teaches you the
> process
> of going from a blank screen and a problem statement to a program in a
> systematic manner.
That means I'm abusing it, but whatever. I like its structure and intend to use
it for getting a gradual feel for the language, doing the exercises I find
interesting and skipping the parts that aren't. I hope that this approach will
prevent the writing language A in language B syndrome. I do not follow the
templates - just read the syntax, tutorials and assignments, and think of my own
solution if they strike me as useful. I intend to combine it with the Fixnum
book when I find myself skipping TOO much text.
> 4. Someone who teaches you Scheme (only) may wish to show you loops
> first.
> Things like map and filter and so on. And before you know it, he's shown
> you how to write permutations in 4 lines of code. And after you stare
> long enough at it, you even understand it. But what do you carry
> over from that process to Java, for example?
Exactly. I can program an example like this in an imperative fashion and it is
indeed a few LOCs. But I'm working within the confines of my Scheme knowledge
which makes it more challenging, to me anyway.
Given the fact that I'm doing self-study and have no other way of getting
feedback, I hoped the members of the list would be willing to act as a sounding
board on the quality of the solution - if necessary in private so as to not make
my publication of the code even worse.
Andrew