From 15cbf6b594e81fddc5ad4666789855f85faf741b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 23 Oct 2022 10:24:18 -0500 Subject: Add: pop-nth --- utilities.lisp | 8 ++++++++ 1 file changed, 8 insertions(+) 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)))) -- cgit v1.2.3