Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Macgyver :D

Name: Anonymous 2009-10-14 0:22

i just wanna be like him
:)

Name: Anonymous 2009-10-16 19:46

>>60
Here's the non-stable version by the way. It could use a refactoring and I guess I'll do that when I write the stable verson.

(define (split num l)
  (let iter ((original l) (lt '()) (gt '()))
    (cond ((null? original)
           (list (reverse lt) (reverse gt)))
          ((< (car original) num)
           (iter (cdr original) (cons (car original) lt) gt))
          (else
           (iter (cdr original) lt (cons (car original) gt))))))

(define (qs l)
  (cond ((null? l) l)
        ((null? (cdr l)) l)
        (else
         (let* ((pivot-a (car l))
                (pivot-b (cadr l))
                (rest (cddr l))
                (first (min pivot-a pivot-b))
                (second (max pivot-a pivot-b))
                (split-at-first (split first rest))
                (start (car split-at-first))
                (split-at-second (split second (cadr split-at-first)))
                (middle (car split-at-second))
                (end (cadr split-at-second)))
           (append (qs start) (list first) (qs middle) (list second) (qs end))))))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List