Skip to content

Instantly share code, notes, and snippets.

@ahyatt
Created January 18, 2015 05:40
Show Gist options
  • Save ahyatt/89f3a8a942dc059f260f to your computer and use it in GitHub Desktop.
Save ahyatt/89f3a8a942dc059f260f to your computer and use it in GitHub Desktop.
An example of using the async package to implement sleep-sort.
(setq lexical-binding t)
(defun sleep-sort (numbers)
(let ((sorted-list))
(dolist (n numbers)
(async-start (lambda ()
(sleep-for n))
(lambda (val)
(add-to-list 'sorted-list n)
(when (= (length numbers)
(length sorted-list))
(message "Sorted list: %s"
(nreverse sorted-list))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment