diff options
author | Colin Okay <okay@toyful.space> | 2022-02-28 09:40:33 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-28 09:40:33 -0600 |
commit | 808b68d1081b5f1415325cc2848075d4c23ae795 (patch) | |
tree | ba3ae952a35510145ac9680031184a75875c4320 | |
parent | 03af54752e684d471d08126653c057ba7c5b8c5b (diff) |
added some options to qb-look
-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)))) |