;; The first three lines of this file were inserted by DrRacket. They record metadata ;; about the language level of this file in a form that our tools can easily process. #reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname week7_f) (read-case-sensitive #t) (teachpacks ((lib "image.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "image.ss" "teachpack" "htdp"))))) (define (quick-sort l) (cond [(empty? l) empty] [else (append (quick-sort (smaller-than (first l) (rest l))) (list (first l)) (quick-sort (larger-than (first l) (rest l))))])) (define (smaller-than x l) (filter (lambda (y) (< y x)) l)) (define (larger-than x l) (filter (lambda (y) (>= y x)) l)) (check-expect (quick-sort (list 3 3 2 12 11)) (list 2 3 3 11 12))