aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--utilities.lisp6
1 files changed, 5 insertions, 1 deletions
diff --git a/utilities.lisp b/utilities.lisp
index 972df8a..214189f 100644
--- a/utilities.lisp
+++ b/utilities.lisp
@@ -38,7 +38,11 @@
"Creates a new list, the result of inserting X into the Nth position
of LIST, displacing the rest of the elements by one position. If N
is greater than the length of LIST, X becomes the last element of
- LIST. If N is negative, a list containing just X is returned."
+ LIST. If N is negative, the element is inserted from the back of
+ the list. If the abslute value of -N is greater than the lenght of
+ the list, a list just containing X is returned."
+ (when (minusp n)
+ (setf n (+ 1 n (length list))))
(multiple-value-bind (front back) (take n list)
;; NCONC ok b/c this call to TAKE returns values that do not shre
;; memory with LIST