Created
January 25, 2023 08:14
-
-
Save shionryuu/50056c1adcaf91fab42e5993fd89f515 to your computer and use it in GitHub Desktop.
Quick Sort in Racket
This file contains 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
#lang racket | |
; author ka__ka__ | |
(define (quick-sort array) | |
(cond | |
[(empty? array) empty] ; 快排的思想是分治+递归 | |
[else (append | |
(quick-sort (filter (lambda (x) (< x (first array))) array)) ; 这里的 array 就是闭包 | |
(filter (lambda (x) (= x (first array))) array) | |
(quick-sort (filter (lambda (x) (> x (first array))) array)))])) | |
(quick-sort '(1 3 2 5 3 4 5 0 9 82 4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment