Hacker News new | ask | show | jobs
by JimmyM 4443 days ago
This is how I usually implemented quicksort in Racket:

    (define (quicksort xs)
    (if (null? xs)
    xs
    (let* 
        ([hd (car xs)] 
         [tail (cdr xs)]
         [smaller (filter (lambda (x) (< x hd)) tail)]
         [bigger (filter (lambda (x) (>= x hd)) tail)])
      (append (quicksort smaller) (list hd) (quicksort bigger))))
It's great to see a hugely superior implementation, and I love that people are writing about and using Racket like this because the more people do that the more resources there will be for people like me to learn from.