;; The first three lines of this file were inserted by DrScheme. 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 |26.3|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))))) ;qsort : (listof number) -> (listof number) ;Uses generative recursion to quickly sort alon. (define (qsort alon) (cond [(empty? alon) empty] [else (append (qsort (filter (lambda (x) (< x (first alon))) (rest alon))) (list (first alon)) (qsort (filter (lambda (x) (> x (first alon))) (rest alon))))])) qsort-filter : (number number -> boolean) number (listof numbers) -> (listof numbers) Returns a (listof numbers) for all numbers in alon that when compared to anumber satisfies (filter number alon). (define (filter-qsort operator anumber alon) (filter (lambda (x) (< x (first alon))) (rest alon))