# HG changeset patch
# User Steve Losh <steve@stevelosh.com>
# Date 1596826201 14400
# Node ID 33ec50895f68ea8950ddc82701f16832c433e311
# Parent  c5a16c723abb21de8954b69bd3105796cb789a49
Add 1in

diff -r c5a16c723abb -r 33ec50895f68 src/math.lisp
--- a/src/math.lisp	Fri Feb 28 20:36:35 2020 -0500
+++ b/src/math.lisp	Fri Aug 07 14:50:01 2020 -0400
@@ -54,11 +54,17 @@
   "Coerce the top of the stack to a DOUBLE-FLOAT."
   (push! (coerce x 'double-float)))
 
+(define-command 1in (p)
+  "Convert a probability to `1 in X` form and push `X`."
+  (let ((p (rationalize p)))
+    (push! (coerce (/ (denominator p) (numerator p))
+                   'double-float))))
+
 (define-command range (from below)
-  (map nil #'push! (range from below)))
+  (loop for x :from from :below below :do (push! x)))
 
 (define-command irange (from to)
-  (map nil #'push! (range from (1+ to))))
+  (loop for x :from from :to to :do (push! x)))
 
 (define-command base (n)
   "Set the print base and read base for numbers to the top element of the stack.