Skip to content

Instantly share code, notes, and snippets.

@git2samus
Created April 9, 2012 04:34
Show Gist options
  • Select an option

  • Save git2samus/2341447 to your computer and use it in GitHub Desktop.

Select an option

Save git2samus/2341447 to your computer and use it in GitHub Desktop.
lazy merge-sort
(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