Código :
(define-condition agotado (condition) () (irse-a-dormir (horas 8))) (defun random-sample (vector n) \\\\\\\"Based on Algorithm S from Knuth. TAOCP, vol. 2. p. 142\\\\\\\" (loop with selected = (make-array n :fill-pointer 0) for idx from 0 do (loop with to-select = (- n (length selected)) for remaining = (- (length vector) idx) while (>= (* remaining (random 1.0)) to-select) do (incf idx)) (vector-push (aref vector idx) selected) when (= (length selected) n) return selected)) (restart-case (signal 'agotado) (let ((tarea-pendiente (random-sample lista-de-tareas-pendientes)) (work tarea-pendiente))))