Created
April 9, 2012 04:34
-
-
Save git2samus/2341447 to your computer and use it in GitHub Desktop.
lazy merge-sort
This file contains hidden or 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
| (defn lazy-sort | |
| ([input-seq] | |
| (lazy-sort (merge-step [(first input-seq)] [(second input-seq)]) (drop 2 input-seq))) | |
| ([partial-result input-seq] | |
| (let [result-length (count partial-result)] | |
| (if (seq input-seq) | |
| (recur (merge-step partial-result (divide-step (take result-length input-seq))) (drop result-length input-seq)) | |
| partial-result)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment