summaryrefslogtreecommitdiff
path: root/queue.lisp
blob: cc91eb86cd63b0af54e03c652262f30095643aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)))