gists/gists/apply-maybe.el

6 lines
190 B
EmacsLisp

(defun my/apply-maybe (f probability &rest args)
"Apply function F with a certain PROBABILITY [0-1)."
(if (< (random 100) (* probability 100))
(apply f args)
'my/not-applied))