Created
December 5, 2011 05:22
-
-
Save phelrine/1432415 to your computer and use it in GitHub Desktop.
quick sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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