fork download
  1. (defun factorial (n)
  2. (check-type n (integer 0 *))
  3. (loop :for fact = 1 :then (* fact i)
  4. :and i :from 1 :to n
  5. :finally (return fact)))
  6.  
  7. (defun factorials (&rest args)
  8. (loop :for x :in args
  9. :collect (restart-case (factorial x)
  10. (skip-this-shit (&optional y) y))))
  11.  
  12. (defun fix-input (cond)
  13. (typecase #1=(type-error-datum cond)
  14. ((integer * 0) (store-value (abs #1#)))
  15. (real (store-value (floor #1#)))
  16. (t (invoke-restart 'skip-this-shit :skipped))))
  17.  
  18. (handler-bind ((type-error #'fix-input))
  19. (print (factorials 1 5.2 2 3 "sasai" -1 5 6)))
  20.  
Success #stdin #stdout 0s 10528KB
stdin
Standard input is empty
stdout
(1 120 2 6 :SKIPPED 1 120 720)