[plt-scheme] Re: Novice needs help writing function

From: dave yrueta (dyrueta at gmail.com)
Date: Sun Dec 30 20:02:49 EST 2007


On Dec 30, 7:47 am, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> Perhaps I misunderstood your question but this is a perfectly fine
> solution.
>
> On Dec 29, 2007, at 2:35 PM, dave yrueta wrote:
>
>
>
> > Thanks for all the input everyone.
>
> > I took N's advice, revisited the problem by stepping through the
> > design recipe, and came up with the following core and auxiliary
> > functions which cheat a bit....
>
> > (define (apply-n1 face count)
> >    (cond
> >       [(zero? count) (draw-losh face)]
> >       [else (apply-n3(move-picture 1 face)(sub1 count))]))
>
> > (define (apply-n count)
> >   (apply-n3 FACE count))
>
> > Does this solution satisfy the pedagogical function of the problem?
>
> > Also, cheers to M. for a wonderful book!  For awhile I've had an
> > interest in computer programming, but career obligations have
> > relegated it to a hobby.  For someone like me, who has never taken a
> > CS course and is not very good at math, the text is a godsend!
>
> > Having come across the concept of recursion in general interest texts
> > like Godel Escher Bach and Godel's Proof, thanks to HTDP, I finally
> > feel as though I've gained some basic understanding of how it works.
> > I'm not sure if this is the appropriate forum, but I was wondering if
> > anyone could recommend a good introductory text on recursion
> > comprehensible to a non-specialist like myself.  I think it's a
> > fascinating topic, and I'd love to learn more about it.
>
> HtDP :-)
>
> What are you looking for and may I forward the paragraphs (minus the
> praise) to the PLT mailing list for educators. -- Matthias
>
> Hi Matthias --

I'm looking for a text which, first and foremost, attempts to explain
recursion from a naive point of view -- that is, from the perspective
of someone who is encountering it for the first time (by the way, I
think HtDP does a very good job of this).  Too many introductory texts
I've consulted start slow, spend a great deal of time discussing very
elementary examples, and then make a sudden quantum leap in complexity
while going mute on explanations.  It's very frustrating.

A good example of this occurred in a VB text I took up in my study of
programming, and marked my first exposure to the recursion in a CS
context.  I was working through a chapter on arrays and the authors
threw in recursion almost as an afterthought, including only a very
brief discussion and a function which computed factorials as their
single example.   The concluding exercises consisted of about 20
problems on arrays but only one on recursion -- Hanoi Towers -- which
nearly drove me to seek out the top of their physical counterparts for
a place to leap from.  My feeling is that the solution to the Hanoi
Towers problem is of a much higher order of complexity than solving
factorials, and that the move from one to the other, in the context of
an introductory educational text, was unjustified.

So the second thing I'm looking for is a text which is sensitive to
this issue, and at least makes an attempt to discern levels of
complexity among the classes of problems suited for recursive
solutions.

Third, while sifting layers of complexity, it might also try to
identify certain types of recursive problem-solving techniques and
link them to generic problem types. For example, I downloaded a paper
which purported to develop something akin to a "design recipe" for
recursive algorithms. The single example was a function summing the
digits of a number.  The discussion was very good, but I don't beleive
the technique was fertile enough to lead to solutions for problems
requiring a "branched" approach, like Fibonacci, for example.

Last, as I mentioned before, it should be pitched to the non-
specialist, like HtDP.

I've ordered a book by a Standford CS prof named Eric Roberts called
"Thinking Recursively," whose description seems tailored to needs like
mine. If you know of any others, please let me know.  I was a
philosophy student in college but now I run a business, so my interest
in recursion is twofold -- intellectual (hence Hofstadter) and
practical (it seems like a very powerful problem solving tool that
might be useful in developing small-scale database applications).

Please feel free to forward this e-mail to anyone who might be
interested in responding.  Thanks a bunch for reading!

Finally, without trying to beat a dead horse, but in regards to your
last comment--

"Sorry, after looking over the code, I think you should send us the
WHOLE design before I make any other comment any more."

-- I couldn't quite make out your meaning.  Do I need to revisit the
problem and seek a different solution, or were you referring to the
fact that the "move-picture" function already includes the "clear-
picture" function which your original comments directed me to?

Thanks again!

DY


>
> > On Dec 29, 7:14 am, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> >> In this particular case, the problem is on my side. Working
> >> with draw.ss just doesn't fit with the natural development of
> >> the design recipe. I should have taken this symptom more seriously
> >> when I wrote this extended exercise. -- Matthias
>
> >> On Dec 29, 2007, at 8:42 AM, Noel Welsh wrote:
>
> >>> The design recipes are a (if not the) core part of HtDP.  HtDP is
> >>> the
> >>> only book I know that takes designing programs from a dark and
> >>> mysterious art to a systematic process anyone can apply.  This is a
> >>> really really powerful idea.  So, if you haven't worked through the
> >>> design recipe, do so.  If you have, then you might say what
> >>> difficulties you are having applying the recipe.
>
> >>> N.
> >>> _________________________________________________
> >>>   For list-related administrative tasks:
> >>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> >> _________________________________________________
> >>   For list-related administrative tasks:
> >>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > _________________________________________________
> >   For list-related administrative tasks:
> >  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.