diff options
-rw-r--r-- | src/util.lisp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/util.lisp b/src/util.lisp index aab4bf6..a1709bb 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -52,9 +52,16 @@ (t default)))) -(defun qb-look (q) - "get a list of the queue, but don't remove items from it" +(defun qb-look (q &key limit reversep) + "Get a list of the queue, but don't remove items from it. REVERSEP, +when T, Puts the newest items first." + ;TODO: an inefficient but straightforward implementation, possibly improve. (with-slots (front back) q - (nconc (copy-seq front) - (reverse back)))) + (let ((seq + (if reversep + (nconc (copy-seq back) (reverse front)) + (nconc (copy-seq front) (reverse back))))) + (if limit + (a:subseq* seq 0 limit) + seq)))) |