aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-28 09:40:33 -0600
committerColin Okay <okay@toyful.space>2022-02-28 09:40:33 -0600
commit808b68d1081b5f1415325cc2848075d4c23ae795 (patch)
treeba3ae952a35510145ac9680031184a75875c4320
parent03af54752e684d471d08126653c057ba7c5b8c5b (diff)
added some options to qb-look
-rw-r--r--src/util.lisp15
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))))