chiark
/
gitweb
/
~mdw
/
lisp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sys-base.lisp (set-command-line-arguments): Rewrite to use `uiop' properly.
[lisp]
/
queue.lisp
diff --git
a/queue.lisp
b/queue.lisp
index 49c69c5c2189d15d23ec7e9da65c5b76591335e0..44ec5343b0a37382ef12e43195d209ac9e468aec 100644
(file)
--- a/
queue.lisp
+++ b/
queue.lisp
@@
-22,10
+22,10
@@
;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
(defpackage #:queue
;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
(defpackage #:queue
- (:use #:common-lisp)
- (:export #:make-queue #:queue-emptyp #:enqueue #:pushqueue #:dequeue))
+ (:use #:common-lisp))
(in-package #:queue)
(in-package #:queue)
+(export 'make-queue)
(defun make-queue ()
"Make a new queue object."
;; A queue is just a cons cell. The cdr is the head of the list of items
(defun make-queue ()
"Make a new queue object."
;; A queue is just a cons cell. The cdr is the head of the list of items
@@
-35,16
+35,19
@@
(defun make-queue ()
(let ((q (cons nil nil)))
(setf (car q) q)))
(let ((q (cons nil nil)))
(setf (car q) q)))
+(export 'queue-emptyp)
(defun queue-emptyp (q)
"Answer whether the queue Q is empty."
(null (cdr q)))
(defun queue-emptyp (q)
"Answer whether the queue Q is empty."
(null (cdr q)))
+(export 'enqueue)
(defun enqueue (x q)
"Enqueue the object X into the queue Q."
(let ((c (cons x nil)))
(setf (cdr (car q)) c
(car q) c)))
(defun enqueue (x q)
"Enqueue the object X into the queue Q."
(let ((c (cons x nil)))
(setf (cdr (car q)) c
(car q) c)))
+(export 'pushqueue)
(defun pushqueue (x q)
"Push the object X onto the front of the queue Q."
(let* ((first (cdr q))
(defun pushqueue (x q)
"Push the object X onto the front of the queue Q."
(let* ((first (cdr q))
@@
-52,6
+55,7
@@
(defun pushqueue (x q)
(setf (cdr q) new)
(unless first (setf (car q) new))))
(setf (cdr q) new)
(unless first (setf (car q) new))))
+(export 'dequeue)
(defun dequeue (q)
"Remove and return the object at the head of the queue Q."
(if (queue-emptyp q)
(defun dequeue (q)
"Remove and return the object at the head of the queue Q."
(if (queue-emptyp q)