diff options
author | Colin Okay <colin@cicadas.surf> | 2022-10-23 10:24:18 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-10-23 10:24:18 -0500 |
commit | 15cbf6b594e81fddc5ad4666789855f85faf741b (patch) | |
tree | f0b0fb0fde6fcccea0163cd2eaff1d3a159f24eb /utilities.lisp | |
parent | 45126b5bc5ded7dc056717d017b2413921b3e42a (diff) |
Add: pop-nth
Diffstat (limited to 'utilities.lisp')
-rw-r--r-- | utilities.lisp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/utilities.lisp b/utilities.lisp index 214189f..69ddcfe 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -55,3 +55,11 @@ (setf (nth n list) (nth m list) (nth m list) tmp) list)) + +(defun pop-nth (n list &optional share-tail) + (when (minusp n) + (setf n (+ n (length list)))) + (multiple-value-bind (front back) (take n list share-tail) + (values + (nconc front (cdr back)) + (car back)))) |