[plt-scheme] Do no evil
Just a few quick notes:
- You can still use the design recipe. The induction / recursion is
over the indices rather than directly over the elements. So your
template looks something like:
(define (bubble-sort v i)
(cond
[(= i (vector-length v) ... finish recursion ...]
[else ... (vector-ref v i) ... (bubble-sort v (add1 i)) ...]))
(This is from someone with hazy recollection of HtDP)
I'd break out the swap operation into a separate function. This is the
only part that should introduce mutation. You could implement a
immutable swap (i.e. a copy) to show the students the mutation is not
fundamental.
HTH,
N.