From 808b68d1081b5f1415325cc2848075d4c23ae795 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Mon, 28 Feb 2022 09:40:33 -0600 Subject: added some options to qb-look --- src/util.lisp | 15 +++++++++++---- 1 file 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)))) -- cgit v1.2.3