[plt-scheme] Quicksort in Scheme

From: Joe Marshall (jmarshall at alum.mit.edu)
Date: Wed Jan 4 15:18:57 EST 2006

On 1/4/06, Matt Jadud <mcj4 at kent.ac.uk> wrote:
> I've always wondered: why does Scheme have cons, but not snoc? A point
> of history, a point of practicality, neither, or both?

Presumably snoc would work like this?

(snoc '(a b c d e) 'f) =>  '(a b c d e f)

This is trivial to write, and you could write several utilities based on it.

(define (bad-append left right)
  (if (null? right)
      left
      (bad-append (snoc left (first right)) (rest right))))

Now, what is the order of growth of bad-append in l and r?  How would
this scale?
What would be a practical limit?

--
~jrm


Posted on the users mailing list.