From ca2362bc53b548c1e0b2a725545984854fe62413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Sun, 30 Oct 2022 18:28:18 -0300 Subject: Initial Commit --- queue.lisp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 queue.lisp (limited to 'queue.lisp') 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))) -- cgit v1.2.3