Skip to content

Instantly share code, notes, and snippets.

@shionryuu
Created January 25, 2023 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shionryuu/50056c1adcaf91fab42e5993fd89f515 to your computer and use it in GitHub Desktop.
Save shionryuu/50056c1adcaf91fab42e5993fd89f515 to your computer and use it in GitHub Desktop.
Quick Sort in Racket
#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