On 3/25/2015 2:07 PM, 'John Clements' via users-redirect wrote:
This is a pedagogic question. The discussion below (forwarded with permission) 
is basically about the best way to find the maximum value in a vector of length 
four million, a.k.a. a sound file. Non-tail recursion is problematic; I blow a 
512M-limited evaluator in about 14 seconds without finding the answer, where 
tail-calling gets me the answer in about 2 seconds.

I have to ask ... how exactly did you search a vector non-tail recursively?


So! Here’s the question. Is it better to give students an “rs-foldl” that 
performs a fold over sound, or to show them accumulator-style programming? I 
was a bit surprised to see that in HtDP 2e, foldl (a.k.a. “Programming to an 
Abstraction”) appears much earlier (section 18.4) than accumulator-style 
(section 35). I suppose this could be because using an abstraction can be 
easier than devising it, although in the case of (say) map, the book takes care 
to ensure that students can implement map-like functions in their sleep before 
showing them the abstraction.

Opinions appreciated!

That's tough. On one hand, teaching map and fold shows the proper (IMO) way to *think* about the problem - loops are implementation detail. On the other hand, regarding map and fold as black boxes does not give the student any appreciation of their complexity. It's very much like the loop vs recursion argument: unless you have fought with a loop + auxiliary stack implementation, you don't appreciate what recursion is doing for you automagically, nor do you really appreciate its hidden management costs.

Having learned loops first [because Lisp was, IIRC, my 5th programming language] I can only speculate on the reverse. I can say that it was easy to understand map and fold [reduce in Lisp] in terms of loops and accumulators, but I think that lacking that perspective it would be possible for a student to compartmentalize and disassociate them. There's also the possibility of mistaking implementation for general concept: e.g., people learning "don't use right fold because it takes O(n) space" ... when _we_ know that is due to an implementation detail and not a failing of right fold in general.

I know none of this answers your question.
George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to