# HG changeset patch # User Steve Losh # Date 1470697779 0 # Node ID b1426e8648efb81b727264be49836eddc2060d16 # Parent a25df85e26e5efff271fbfe6125425f649c50918 Fix `random-around` for integer spreads diff -r a25df85e26e5 -r b1426e8648ef losh.lisp --- a/losh.lisp Mon Aug 08 16:29:47 2016 +0000 +++ b/losh.lisp Mon Aug 08 23:09:39 2016 +0000 @@ -118,8 +118,11 @@ (defun random-around (value spread) "Return a random number within `spread` of `value`." - (random-range (- value spread) - (+ value spread))) + (etypecase spread + (integer (random-range (- value spread) + (+ value spread 1))) + (real (random-range (- value spread) + (+ value spread))))) (defun d (n sides &optional (plus 0)) "Roll some dice. @@ -136,8 +139,6 @@ plus)) - - ;;;; Functions (defun juxt (&rest fns) "Return a function that will juxtipose the results of `functions`.