Algorithms
Logic
(ns quicksort.core)
(defn quick-sort [nums]
(if (< (count nums) 2) nums
(concat
(quick-sort (filter #(< % (first nums)) nums))
(filter #(= % (first nums)) nums)
(quick-sort (filter #(> % (first nums)) nums)))))
(ns quicksort.test
(:require [clojure.test :refer :all]
[quicksort.core :refer [quick-sort]]))
(deftest quick-sort-test
(is (= (quick-sort '(2 3 1)) '(1 2 3)))
(is (= (quick-sort '(9 -1 -2 10)) '(-2 -1 9 10)))
(is (= (quick-sort '(1 2 666 233 0 8 34 -1)) '(-1 0 1 2 8 34 233 666))))