Fix `random-around` for integer spreads
author |
Steve Losh <steve@stevelosh.com> |
date |
Mon, 08 Aug 2016 23:09:39 +0000 |
parents |
a25df85e26e5
|
children |
5502971bb4bb
|
branches/tags |
(none) |
files |
losh.lisp |
Changes
--- 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`.