/usr/lib/quicksort.scm is in scheme9 2013.11.26-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2009
; Placed in the Public Domain
;
; (quicksort procecure^2 list) ==> list
;
; Sort lists using the Quicksort algorithm. PROCEDURE^2 is a
; binary procedure describing the desired order. The original
; list is not changed.
;
; Example: (quicksort <= '(5 3 7 9 1)) ==> (1 3 5 7 9)
(load-from-library "partition.scm")
(define (quicksort p a)
(letrec
((sort
(lambda (a)
(if (or (null? a)
(null? (cdr a)))
a
(let ((p* (partition (lambda (x) (p (car a) x))
(cdr a))))
(append (sort (cadr p*))
(list (car a))
(sort (car p*))))))))
(sort a)))
|