(define (winston-sort x predicate) (define (merge a b) (cond ((null? a) b) ((null? b) a) ((predicate (car a) (car b)) (cons (car a) (merge (cdr a) b))) (else (cons (car b) (merge a (cdr b)))))) (define (head l n) (cond ((negative? n) '()) (else (cons (car l) (head (cdr l) (- n 2)))))) (define (tail l n) (cond ((negative? n) l) (else (tail (cdr l) (- n 2))))) (define (first-half l) (head l (- (length l) 1))) (define (last-half l) (tail l (- (length l) 1))) (cond ((null? (cdr x)) x) (else (merge (winston-sort (first-half x) predicate) (winston-sort (last-half x) predicate)))))