Created
January 18, 2015 05:40
-
-
Save ahyatt/89f3a8a942dc059f260f to your computer and use it in GitHub Desktop.
An example of using the async package to implement sleep-sort.
This file contains 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
(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