summaryrefslogtreecommitdiff
path: root/queue.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2022-10-30 18:28:18 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2022-10-30 18:28:18 -0300
commitca2362bc53b548c1e0b2a725545984854fe62413 (patch)
treeac745bc46bbede30c1dc3addeebc5f6f3b1ae3f0 /queue.lisp
downloadutils-ca2362bc53b548c1e0b2a725545984854fe62413.tar.gz
utils-ca2362bc53b548c1e0b2a725545984854fe62413.zip
Initial Commit
Diffstat (limited to 'queue.lisp')
-rw-r--r--queue.lisp29
1 files changed, 29 insertions, 0 deletions
diff --git a/queue.lisp b/queue.lisp
new file mode 100644
index 0000000..cc91eb8
--- /dev/null
+++ b/queue.lisp
@@ -0,0 +1,29 @@
+(in-package #:queue)
+
+(declaim (optimize (speed 3) (safety 0)))
+
+(defun new ()
+ (cons nil nil))
+
+(defun add (q datum)
+ (let ((element (cons datum nil)))
+ (if (car q)
+ (progn
+ (setf (cddr q) element)
+ (setf (cdr q) (cddr q)))
+ (progn
+ (setf (car q) element)
+ (setf (cdr q) element)))
+ q))
+
+(defun sub (q)
+ (pop (car q)))
+
+(defun peek (q)
+ (caar q))
+
+(defun to-list (q)
+ (car q))
+
+(defun from-list (lst)
+ (cons lst (last lst)))