Skip to content

Instantly share code, notes, and snippets.

@phelrine
Created December 5, 2011 05:22
Show Gist options
  • Save phelrine/1432415 to your computer and use it in GitHub Desktop.
Save phelrine/1432415 to your computer and use it in GitHub Desktop.
quick sort
#!/usr/bin/env gosh
(use gauche.collection)
(define (qsort ls)
(if (null? ls)
'()
(receive (left right) (partition (cut < <> (car ls)) (cdr ls))
(append (qsort left) (list (car ls)) (qsort right)))))
(define (main args)
(print (qsort '(8 1 3 6 0 7 5 2 4 9))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment