[plt-scheme] Do no evil

From: Noel Welsh (noelwelsh at gmail.com)
Date: Mon Mar 8 09:52:15 EST 2010

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)
    [(= 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


Posted on the users mailing list.