Sorting algorithms/Sleep sort: Difference between revisions

Add Emacs Lisp
(Pike implementation)
(Add Emacs Lisp)
Line 479:
12
35
</pre>
 
=={{header|Emacs Lisp}}==
GNU Emacs supports threads, but it's more straightforward to do this by just using timers.
Evaluate in the *scratch* buffer by typing <code>C-M-x</code> on the expression:
<lang Lisp>(dolist (i '(3 1 4 1 5 92 65 3 5 89 79 3))
(run-with-timer (* i 0.001) nil 'message "%d" i))</lang>
 
The output printed in the *Messages* buffer is:
<pre>
1 [2 times]
3 [3 times]
4
5 [2 times]
65
79
89
92
</pre>
 
Anonymous user