all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
(defn merge* [left right]
|
||||
(cond (nil? left) right
|
||||
(nil? right) left
|
||||
true (let [[l & *left] left
|
||||
[r & *right] right]
|
||||
(if (<= l r) (cons l (merge* *left right))
|
||||
(cons r (merge* left *right))))))
|
||||
|
||||
(defn merge-sort [L]
|
||||
(let [[l & *L] L]
|
||||
(if (nil? *L)
|
||||
L
|
||||
(let [[left right] (split-at (/ (count L) 2) L)]
|
||||
(merge* (merge-sort left) (merge-sort right))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue