--- a/package.lisp Sat Jul 09 16:29:35 2016 +0000
+++ b/package.lisp Sat Jul 16 22:04:29 2016 +0000
@@ -1,7 +1,9 @@
+; (rename-package :charms :hunchentoot '(:ht))
+
+
(defpackage #:sand.utils
(:use
#:cl
- #:defstar
#:iterate
#:cl-arrows
#:sand.quickutils)
@@ -45,7 +47,6 @@
(defpackage #:sand.random-numbers
(:use
#:cl
- #:defstar
#:iterate
#:cl-arrows
#:sand.quickutils
@@ -56,7 +57,6 @@
(defpackage #:sand.parenscript
(:use
#:cl
- #:defstar
#:sand.quickutils
#:cl-arrows
#:cl-fad
@@ -67,3 +67,10 @@
(:import-from #:sand.utils)
)
+
+(defpackage #:sand.ascii
+ (:use #:cl
+ #:iterate
+ #:cl-arrows
+ #:sand.quickutils
+ #:sand.utils))
--- a/sand.asd Sat Jul 09 16:29:35 2016 +0000
+++ b/sand.asd Sat Jul 16 22:04:29 2016 +0000
@@ -7,7 +7,7 @@
:license "MIT/X11"
:version "0.0.1"
- :depends-on (#:defstar
+ :depends-on (#:cl-charms
#:iterate
#:cl-arrows
#:cl-fad
@@ -21,6 +21,7 @@
:serial t
:components ((:file "utils")
(:file "random-numbers")
+ (:file "ascii")
(:module "parenscript"
:serial t
:components ((:file "compiler")))))))
--- a/src/random-numbers.lisp Sat Jul 09 16:29:35 2016 +0000
+++ b/src/random-numbers.lisp Sat Jul 16 22:04:29 2016 +0000
@@ -9,21 +9,16 @@
(deftype nonnegative-fixnum () `(integer 1 ,most-positive-fixnum))
(deftype nonpositive-fixnum () `(integer ,most-negative-fixnum -1))
+
;;;; Utils
-(defun* +mod ((x nonnegative-fixnum)
- (y nonnegative-fixnum)
- (m positive-fixnum))
+(defun +mod (x y m)
(if (<= x (- m 1 y))
(+ x y)
(- x (- m y))))
;;;; Random Number Generators
-(defun* make-linear-congruential-rng
- ((modulus positive-fixnum)
- (multiplier nonnegative-fixnum)
- (increment nonnegative-fixnum)
- (seed nonnegative-fixnum))
+(defun make-linear-congruential-rng (modulus multiplier increment seed)
(let ((val seed))
(lambda (msg)
(ecase msg
@@ -32,11 +27,7 @@
modulus)))
(:modulus modulus)))))
-(defun* make-linear-congruential-rng-fast%
- ((modulus positive-fixnum)
- (multiplier nonnegative-fixnum)
- (increment nonnegative-fixnum)
- (seed nonnegative-fixnum))
+(defun make-linear-congruential-rng-fast% (modulus multiplier increment seed)
(declare (optimize (speed 3) (safety 0) (debug 0)))
(let ((val seed))
(lambda (msg)
@@ -49,12 +40,10 @@
(declaim (inline rng-next rng-modulus))
-(defun* rng-next ((generator function))
- (:returns positive-fixnum)
+(defun rng-next (generator)
(funcall generator :next))
-(defun* rng-modulus ((generator function))
- (:returns positive-fixnum)
+(defun rng-modulus (generator)
(funcall generator :modulus))
@@ -90,8 +79,7 @@
;;; A B C A B C A B
;;;
;;; Notice that it's not uniform.
-(defun* monte-carlo ((width positive-fixnum))
- (:returns positive-fixnum)
+(defun monte-carlo (width)
(mod (rng-next *generator*) width))
@@ -101,8 +89,7 @@
;;;
;;; 1 2 3 4 5 6 7 8
;;; A A B B C C retry
-(defun* las-vegas ((width positive-fixnum))
- (:returns positive-fixnum)
+(defun las-vegas (width)
(let* ((modulus (rng-modulus *generator*))
(bucket-width (truncate (/ modulus width))))
(iterate
--- a/src/utils.lisp Sat Jul 09 16:29:35 2016 +0000
+++ b/src/utils.lisp Sat Jul 16 22:04:29 2016 +0000
@@ -159,51 +159,3 @@
,(when (and (null var) (null per))
`(finally (return ,since)))))))
-
-;;;; Queues
-;;; From PAIP (thanks, Norvig).
-
-(deftype queue () '(cons list list))
-
-(declaim (inline queue-contents make-queue
- enqueue dequeue
- queue-empty-p queue-append))
-
-
-(defun* queue-contents ((q queue))
- (:returns list)
- (cdr q))
-
-(defun* make-queue ()
- (:returns queue)
- (let ((q (cons nil nil)))
- (setf (car q) q)))
-
-(defun* enqueue ((item t) (q queue))
- (:returns queue)
- (setf (car q)
- (setf (rest (car q))
- (cons item nil)))
- q)
-
-(defun* dequeue ((q queue))
- (:returns t)
- (prog1
- (pop (cdr q))
- (if (null (cdr q))
- (setf (car q) q))))
-
-(defun* queue-empty-p ((q queue))
- (:returns boolean)
- (null (queue-contents q)))
-
-(defun* queue-append ((q queue) (l list))
- (:returns queue)
- (when l
- (setf (car q)
- (last (setf (rest (car q))
- l))))
- q)
-
-
-